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

Issue 2500493002: Prevent bad casting in ImageBitmap when calling ArrayBuffer::createOrNull (Closed)

Created:
4 years, 1 month ago by xidachen
Modified:
4 years, 1 month ago
Reviewers:
Justin Novosad
CC:
chromium-reviews, blink-reviews
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Prevent bad casting in ImageBitmap when calling ArrayBuffer::createOrNull Currently when ImageBitmap's constructor is invoked, we check whether dstSize will overflow size_t or not. The problem comes when we call ArrayBuffer::createOrNull some times in the code. Both parameters of ArrayBuffer::createOrNull are unsigned. In ImageBitmap when we call this method, the first parameter is usually width * height. This could overflow unsigned even if it has been checked safe with size_t, the reason is that unsigned is a 32-bit value on 64-bit systems, while size_t is a 64-bit value. This CL makes a change such that we check whether the dstSize will overflow unsigned or not. In this case, we can guarantee that createOrNull will not have any crash. BUG=664139 Committed: https://crrev.com/d59a4441697f6253e7dc3f7ae5caad6e5fd2c778 Cr-Commit-Position: refs/heads/master@{#431936}

Patch Set 1 #

Total comments: 2

Patch Set 2 : change all size_t to unsigned #

Unified diffs Side-by-side diffs Delta from patch set Stats (+48 lines, -42 lines) Patch
M third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-invalid-args.html View 1 3 chunks +14 lines, -10 lines 0 comments Download
M third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-invalid-args-expected.txt View 1 1 chunk +2 lines, -1 line 0 comments Download
M third_party/WebKit/Source/core/frame/ImageBitmap.cpp View 1 14 chunks +32 lines, -31 lines 0 comments Download

Messages

Total messages: 19 (10 generated)
xidachen
PTAL
4 years, 1 month ago (2016-11-11 14:18:33 UTC) #2
Justin Novosad
There should be a test in this CL. https://codereview.chromium.org/2500493002/diff/1/third_party/WebKit/Source/core/frame/ImageBitmap.cpp File third_party/WebKit/Source/core/frame/ImageBitmap.cpp (right): https://codereview.chromium.org/2500493002/diff/1/third_party/WebKit/Source/core/frame/ImageBitmap.cpp#newcode130 third_party/WebKit/Source/core/frame/ImageBitmap.cpp:130: numElement ...
4 years, 1 month ago (2016-11-11 14:40:29 UTC) #3
Justin Novosad
> https://codereview.chromium.org/2500493002/diff/1/third_party/WebKit/Source/core/frame/ImageBitmap.cpp#newcode146 > third_party/WebKit/Source/core/frame/ImageBitmap.cpp:146: size_t width = > static_cast<size_t>(input->width()); > Here width is size_t, but ...
4 years, 1 month ago (2016-11-11 14:42:25 UTC) #4
xidachen
I have changed the CL description, please take a look at the new patch. The ...
4 years, 1 month ago (2016-11-11 15:42:58 UTC) #6
Justin Novosad
lgtm
4 years, 1 month ago (2016-11-14 18:14:01 UTC) #7
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2500493002/20001
4 years, 1 month ago (2016-11-14 19:47:06 UTC) #12
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2500493002/20001
4 years, 1 month ago (2016-11-14 20:33:56 UTC) #15
commit-bot: I haz the power
Committed patchset #2 (id:20001)
4 years, 1 month ago (2016-11-14 22:53:23 UTC) #17
commit-bot: I haz the power
4 years, 1 month ago (2016-11-14 22:59:12 UTC) #19
Message was sent while issue was closed.
Patchset 2 (id:??) landed as
https://crrev.com/d59a4441697f6253e7dc3f7ae5caad6e5fd2c778
Cr-Commit-Position: refs/heads/master@{#431936}

Powered by Google App Engine
This is Rietveld 408576698