Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Unified Diff: ui/base/clipboard/clipboard_win.cc

Issue 2834893002: Ensure ClipboardWin::ReadHTML does not crash on embedded nulls (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/clipboard/clipboard_win.cc
diff --git a/ui/base/clipboard/clipboard_win.cc b/ui/base/clipboard/clipboard_win.cc
index ae892c9c0faa8b985aaeb342fb0e018fd5b852e4..5e42d993427e9f5f55107f7fc1439ea124b5a4e5 100644
--- a/ui/base/clipboard/clipboard_win.cc
+++ b/ui/base/clipboard/clipboard_win.cc
@@ -569,7 +569,10 @@ void ClipboardWin::ReadHTML(ClipboardType type,
markup->assign(base::UTF8ToUTF16AndAdjustOffsets(cf_html.data() + html_start,
&offsets));
*fragment_start = base::checked_cast<uint32_t>(offsets[0]);
- *fragment_end = base::checked_cast<uint32_t>(offsets[1]);
+
+ // Ensure EndFragment points within the string; see https://crbug.com/607181.
+ *fragment_end =
+ base::checked_cast<uint32_t>(std::min(offsets[1], markup->length()));
dcheng 2017/04/22 08:25:25 Should we do this for offsets[0] as well?
elawrence 2017/04/25 16:20:19 Embedded nulls (the known repro case) aren't probl
dcheng 2017/04/26 00:42:08 Why can't embedded nulls appear before fragment st
elawrence 2017/04/26 15:11:22 Ah, you're right in the general case. In the case
}
void ClipboardWin::ReadRTF(ClipboardType type, std::string* result) const {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698