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

Side by Side Diff: webkit/plugins/ppapi/ppb_image_data_impl.cc

Issue 11410081: Security fix: integer overflow on checking image size (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 1 month 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 #include "webkit/plugins/ppapi/ppb_image_data_impl.h" 5 #include "webkit/plugins/ppapi/ppb_image_data_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 } 47 }
48 48
49 bool PPB_ImageData_Impl::Init(PP_ImageDataFormat format, 49 bool PPB_ImageData_Impl::Init(PP_ImageDataFormat format,
50 int width, int height, 50 int width, int height,
51 bool init_to_zero) { 51 bool init_to_zero) {
52 // TODO(brettw) this should be called only on the main thread! 52 // TODO(brettw) this should be called only on the main thread!
53 if (!IsImageDataFormatSupported(format)) 53 if (!IsImageDataFormatSupported(format))
54 return false; // Only support this one format for now. 54 return false; // Only support this one format for now.
55 if (width <= 0 || height <= 0) 55 if (width <= 0 || height <= 0)
56 return false; 56 return false;
57 if (static_cast<int64>(width) * static_cast<int64>(height) * 4 >= 57 if (static_cast<int64>(width) * static_cast<int64>(height) >=
58 std::numeric_limits<int32>::max()) 58 std::numeric_limits<int32>::max() / 4)
59 return false; // Prevent overflow of signed 32-bit ints. 59 return false; // Prevent overflow of signed 32-bit ints.
60 60
61 format_ = format; 61 format_ = format;
62 width_ = width; 62 width_ = width;
63 height_ = height; 63 height_ = height;
64 return backend_->Init(this, format, width, height, init_to_zero); 64 return backend_->Init(this, format, width, height, init_to_zero);
65 } 65 }
66 66
67 // static 67 // static
68 PP_Resource PPB_ImageData_Impl::CreatePlatform(PP_Instance instance, 68 PP_Resource PPB_ImageData_Impl::CreatePlatform(PP_Instance instance,
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 } 278 }
279 279
280 const SkBitmap* ImageDataNaClBackend::GetMappedBitmap() const { 280 const SkBitmap* ImageDataNaClBackend::GetMappedBitmap() const {
281 if (!IsMapped()) 281 if (!IsMapped())
282 return NULL; 282 return NULL;
283 return &skia_bitmap_; 283 return &skia_bitmap_;
284 } 284 }
285 285
286 } // namespace ppapi 286 } // namespace ppapi
287 } // namespace webkit 287 } // namespace webkit
288
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