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

Side by Side 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, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Many of these functions are based on those found in 5 // Many of these functions are based on those found in
6 // webkit/port/platform/PasteboardWin.cpp 6 // webkit/port/platform/PasteboardWin.cpp
7 7
8 #include "ui/base/clipboard/clipboard_win.h" 8 #include "ui/base/clipboard/clipboard_win.h"
9 9
10 #include <shellapi.h> 10 #include <shellapi.h>
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 return; 561 return;
562 562
563 if (start_index < html_start || end_index < start_index) 563 if (start_index < html_start || end_index < start_index)
564 return; 564 return;
565 565
566 std::vector<size_t> offsets; 566 std::vector<size_t> offsets;
567 offsets.push_back(start_index - html_start); 567 offsets.push_back(start_index - html_start);
568 offsets.push_back(end_index - html_start); 568 offsets.push_back(end_index - html_start);
569 markup->assign(base::UTF8ToUTF16AndAdjustOffsets(cf_html.data() + html_start, 569 markup->assign(base::UTF8ToUTF16AndAdjustOffsets(cf_html.data() + html_start,
570 &offsets)); 570 &offsets));
571 *fragment_start = base::checked_cast<uint32_t>(offsets[0]); 571 // Ensure the Fragment points within the string; see https://crbug.com/607181.
572 *fragment_end = base::checked_cast<uint32_t>(offsets[1]); 572 size_t end = std::min(offsets[1], markup->length());
573 *fragment_start = base::checked_cast<uint32_t>(std::min(offsets[0], end));
574 *fragment_end = base::checked_cast<uint32_t>(end);
573 } 575 }
574 576
575 void ClipboardWin::ReadRTF(ClipboardType type, std::string* result) const { 577 void ClipboardWin::ReadRTF(ClipboardType type, std::string* result) const {
576 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE); 578 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE);
577 579
578 ReadData(GetRtfFormatType(), result); 580 ReadData(GetRtfFormatType(), result);
579 } 581 }
580 582
581 SkBitmap ClipboardWin::ReadImage(ClipboardType type) const { 583 SkBitmap ClipboardWin::ReadImage(ClipboardType type) const {
582 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE); 584 DCHECK_EQ(type, CLIPBOARD_TYPE_COPY_PASTE);
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 if (!clipboard_owner_) 900 if (!clipboard_owner_)
899 return NULL; 901 return NULL;
900 902
901 if (clipboard_owner_->hwnd() == NULL) 903 if (clipboard_owner_->hwnd() == NULL)
902 clipboard_owner_->Create(base::Bind(&ClipboardOwnerWndProc)); 904 clipboard_owner_->Create(base::Bind(&ClipboardOwnerWndProc));
903 905
904 return clipboard_owner_->hwnd(); 906 return clipboard_owner_->hwnd();
905 } 907 }
906 908
907 } // namespace ui 909 } // namespace ui
OLDNEW
« 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