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

Unified Diff: WebCore/html/canvas/DataView.cpp

Issue 5556003: Merge 73208 - Integer calculation issues in DataView constructor... (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/597/
Patch Set: Created 10 years 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 | « LayoutTests/fast/canvas/webgl/data-view-crash-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: WebCore/html/canvas/DataView.cpp
===================================================================
--- WebCore/html/canvas/DataView.cpp (revision 73211)
+++ WebCore/html/canvas/DataView.cpp (working copy)
@@ -29,6 +29,8 @@
#include "DataView.h"
+#include "CheckedInt.h"
+
namespace {
template<typename T>
@@ -43,8 +45,13 @@
PassRefPtr<DataView> DataView::create(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned byteLength)
{
- if (byteOffset + byteLength > buffer->byteLength())
+ if (byteOffset > buffer->byteLength())
return 0;
+ CheckedInt<uint32_t> checkedOffset(byteOffset);
+ CheckedInt<uint32_t> checkedLength(byteLength);
+ CheckedInt<uint32_t> checkedMax = checkedOffset + checkedLength;
+ if (!checkedMax.valid() || checkedMax.value() > buffer->byteLength())
+ return 0;
return adoptRef(new DataView(buffer, byteOffset, byteLength));
}
« no previous file with comments | « LayoutTests/fast/canvas/webgl/data-view-crash-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698