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

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

Issue 2834893002: Ensure ClipboardWin::ReadHTML does not crash on embedded nulls (Closed)
Patch Set: Be smarter 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..f1c7c038a5083de2cd4f8b84908ca7a4fe9b8a20 100644
--- a/ui/base/clipboard/clipboard_win.cc
+++ b/ui/base/clipboard/clipboard_win.cc
@@ -568,8 +568,10 @@ void ClipboardWin::ReadHTML(ClipboardType type,
offsets.push_back(end_index - html_start);
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 the Fragment points within the string; see https://crbug.com/607181.
+ size_t end = std::min(offsets[1], markup->length());
+ *fragment_start = base::checked_cast<uint32_t>(std::min(offsets[0], end));
+ *fragment_end = base::checked_cast<uint32_t>(end);
}
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