OLD | NEW |
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/gfx/size.h" |
7 #include "base/logging.h" | 8 #include "base/logging.h" |
8 | 9 |
9 namespace { | 10 namespace { |
10 | 11 |
11 // A compromised renderer could send us bad data, so validate it. | 12 // A compromised renderer could send us bad data, so validate it. |
12 bool IsBitmapSafe(const Clipboard::ObjectMapParams& params) { | 13 bool IsBitmapSafe(const Clipboard::ObjectMapParams& params) { |
13 const gfx::Size* size = | 14 const gfx::Size* size = |
14 reinterpret_cast<const gfx::Size*>(&(params[1].front())); | 15 reinterpret_cast<const gfx::Size*>(&(params[1].front())); |
15 return params[0].size() == | 16 return params[0].size() == |
16 static_cast<size_t>(size->width() * size->height() * 4); | 17 static_cast<size_t>(size->width() * size->height() * 4); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 if (!IsBitmapSafe(params)) | 56 if (!IsBitmapSafe(params)) |
56 return; | 57 return; |
57 WriteBitmap(&(params[0].front()), &(params[1].front())); | 58 WriteBitmap(&(params[0].front()), &(params[1].front())); |
58 break; | 59 break; |
59 #endif // defined(OS_WIN) || defined(OS_LINUX) | 60 #endif // defined(OS_WIN) || defined(OS_LINUX) |
60 | 61 |
61 default: | 62 default: |
62 NOTREACHED(); | 63 NOTREACHED(); |
63 } | 64 } |
64 } | 65 } |
OLD | NEW |