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

Side by Side Diff: base/clipboard.cc

Issue 53040: Validate clipboard bitmap size data. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 9 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 | Annotate | Revision Log
« 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 #include "base/clipboard.h" 5 #include "base/clipboard.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 namespace {
10
11 // A compromised renderer could send us bad data, so validate it.
12 bool IsBitmapSafe(const Clipboard::ObjectMapParams& params) {
13 const gfx::Size* size = reinterpret_cast<const gfx::Size*>(params[1].data());
14 return params[0].size() ==
15 static_cast<size_t>(size->width() * size->height() * 4);
16 }
17
18 }
19
9 void Clipboard::DispatchObject(ObjectType type, const ObjectMapParams& params) { 20 void Clipboard::DispatchObject(ObjectType type, const ObjectMapParams& params) {
10 switch (type) { 21 switch (type) {
11 case CBF_TEXT: 22 case CBF_TEXT:
12 WriteText(&(params[0].front()), params[0].size()); 23 WriteText(&(params[0].front()), params[0].size());
13 break; 24 break;
14 25
15 case CBF_HTML: 26 case CBF_HTML:
16 if (params.size() == 2) 27 if (params.size() == 2)
17 WriteHTML(&(params[0].front()), params[0].size(), 28 WriteHTML(&(params[0].front()), params[0].size(),
18 &(params[1].front()), params[1].size()); 29 &(params[1].front()), params[1].size());
(...skipping 14 matching lines...) Expand all
33 case CBF_FILES: 44 case CBF_FILES:
34 WriteFiles(&(params[0].front()), params[0].size()); 45 WriteFiles(&(params[0].front()), params[0].size());
35 break; 46 break;
36 47
37 case CBF_WEBKIT: 48 case CBF_WEBKIT:
38 WriteWebSmartPaste(); 49 WriteWebSmartPaste();
39 break; 50 break;
40 51
41 #if defined(OS_WIN) || defined(OS_LINUX) // This is just a stub on Linux 52 #if defined(OS_WIN) || defined(OS_LINUX) // This is just a stub on Linux
42 case CBF_BITMAP: 53 case CBF_BITMAP:
54 if (!IsBitmapSafe(params))
55 return;
43 WriteBitmap(&(params[0].front()), &(params[1].front())); 56 WriteBitmap(&(params[0].front()), &(params[1].front()));
44 break; 57 break;
45 #endif // defined(OS_WIN) || defined(OS_LINUX) 58 #endif // defined(OS_WIN) || defined(OS_LINUX)
46 59
47 default: 60 default:
48 NOTREACHED(); 61 NOTREACHED();
49 } 62 }
50 } 63 }
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