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

Issue 2354783004: Fix overflow/underflow in gfx geometry once and for all (Closed)

Created:
4 years, 3 months ago by enne (OOO)
Modified:
4 years, 2 months ago
CC:
cc-bugs_chromium.org, chromium-reviews, danakj, sunxd
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Fix overflow/underflow in ui/gfx once and for all ui/gfx/geometry currently has a number of spots where adding or subtracting two integers can cause overflow or underflow. Fix this so that Point/Vector2d/Size/Rect all correctly clamp integer arithmetic to not fall into undefined overflow or underflow. The behavior is now that any operation that would have overflowed or underflowed is now clamped to the max or min integer. Additionally, for rects, if their size is large enough to overflow right/bottom, this will also be clamped. gfx::Insets is left unchanged as it is only used by ui/views and so is much more likely to be under user control and not overflow. This patch also fixes an overflow error in the unit test that happened in Rect::Inset. BUG=648214 Committed: https://crrev.com/8c14bf7d37bec879a5caa162f2c72a303da1a6e0 Cr-Commit-Position: refs/heads/master@{#423243}

Patch Set 1 #

Total comments: 2

Patch Set 2 : Move to safe integer conversions header #

Patch Set 3 : Now with more tests #

Total comments: 3

Patch Set 4 : Add additional inset test #

Total comments: 2

Patch Set 5 : Fix gn check error #

Patch Set 6 : Whitespace #

Patch Set 7 : Fix for GCC #

Patch Set 8 : Now with 'fix' for accessibility interactive ui test #

Total comments: 2

Patch Set 9 : Remove accessibility test changes #

Unified diffs Side-by-side diffs Delta from patch set Stats (+364 lines, -32 lines) Patch
M ui/gfx/geometry/mojo/geometry.typemap View 1 2 3 4 1 chunk +1 line, -0 lines 0 comments Download
M ui/gfx/geometry/point.h View 1 3 chunks +9 lines, -7 lines 0 comments Download
M ui/gfx/geometry/point_unittest.cc View 1 2 1 chunk +73 lines, -0 lines 0 comments Download
M ui/gfx/geometry/rect.h View 1 2 3 4 5 6 7 8 2 chunks +9 lines, -15 lines 0 comments Download
M ui/gfx/geometry/rect.cc View 1 2 chunks +7 lines, -3 lines 0 comments Download
M ui/gfx/geometry/rect_unittest.cc View 1 2 3 4 5 6 7 8 3 chunks +72 lines, -2 lines 0 comments Download
M ui/gfx/geometry/safe_integer_conversions.h View 1 2 3 4 5 6 1 chunk +46 lines, -0 lines 0 comments Download
M ui/gfx/geometry/safe_integer_conversions_unittest.cc View 1 2 1 chunk +68 lines, -0 lines 0 comments Download
M ui/gfx/geometry/size.cc View 1 2 chunks +2 lines, -1 line 0 comments Download
M ui/gfx/geometry/size_unittest.cc View 1 2 1 chunk +31 lines, -0 lines 0 comments Download
M ui/gfx/geometry/vector2d.cc View 1 2 chunks +5 lines, -4 lines 0 comments Download
M ui/gfx/geometry/vector2d_unittest.cc View 1 2 3 4 5 1 chunk +41 lines, -0 lines 0 comments Download

Messages

Total messages: 42 (26 generated)
enne (OOO)
https://codereview.chromium.org/2354783004/diff/1/ui/gfx/geometry/rect.cc File ui/gfx/geometry/rect.cc (right): https://codereview.chromium.org/2354783004/diff/1/ui/gfx/geometry/rect.cc#newcode67 ui/gfx/geometry/rect.cc:67: origin_ += Vector2d(left, top); Adding and subtracting to vectors ...
4 years, 3 months ago (2016-09-21 00:48:24 UTC) #1
enne (OOO)
PTAL
4 years, 3 months ago (2016-09-21 20:20:30 UTC) #4
danakj
LGTM https://codereview.chromium.org/2354783004/diff/40001/ui/gfx/geometry/rect.cc File ui/gfx/geometry/rect.cc (right): https://codereview.chromium.org/2354783004/diff/40001/ui/gfx/geometry/rect.cc#newcode70 ui/gfx/geometry/rect.cc:70: set_width(SafeSubtract(width(), SafeAdd(left, right))); I think itd be nice ...
4 years, 3 months ago (2016-09-21 22:01:36 UTC) #9
danakj
https://codereview.chromium.org/2354783004/diff/60001/ui/gfx/geometry/rect.h File ui/gfx/geometry/rect.h (left): https://codereview.chromium.org/2354783004/diff/60001/ui/gfx/geometry/rect.h#oldcode216 ui/gfx/geometry/rect.h:216: // 3) We cast the values to unsigned int ...
4 years, 3 months ago (2016-09-21 22:02:08 UTC) #10
enne (OOO)
> It might not fail until landing tho, maybe double check the patch that added ...
4 years, 3 months ago (2016-09-21 22:10:27 UTC) #11
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/2354783004/120001
4 years, 3 months ago (2016-09-22 00:16:29 UTC) #21
commit-bot: I haz the power
Try jobs failed on following builders: linux_chromium_chromeos_ozone_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_chromeos_ozone_rel_ng/builds/239712)
4 years, 3 months ago (2016-09-22 01:22:14 UTC) #23
enne (OOO)
+dmazzoni for some changes to chromeos accessibility unit tests that were depending on integer underflow ...
4 years, 3 months ago (2016-09-23 00:17:06 UTC) #25
enne (OOO)
+dtseng as alternate dmazzoni for chrome/browser/chromeos/accessibility
4 years, 2 months ago (2016-09-30 19:00:08 UTC) #31
enne (OOO)
+plundblad as an alternate dtseng/dmazzoni for chrome/browser/chromeos/accessibility Anybody? ;;
4 years, 2 months ago (2016-10-03 17:16:50 UTC) #33
dmazzoni
https://codereview.chromium.org/2354783004/diff/140001/chrome/browser/chromeos/accessibility/accessibility_highlight_manager.cc File chrome/browser/chromeos/accessibility/accessibility_highlight_manager.cc (right): https://codereview.chromium.org/2354783004/diff/140001/chrome/browser/chromeos/accessibility/accessibility_highlight_manager.cc#newcode21 chrome/browser/chromeos/accessibility/accessibility_highlight_manager.cc:21: (INT_MAX - 1000, INT_MAX - 1000, 0, 0)); On ...
4 years, 2 months ago (2016-10-04 22:29:32 UTC) #34
enne (OOO)
Looks like that fix landed, so I'll land this without those test changes. Thanks again! ...
4 years, 2 months ago (2016-10-05 17:06:42 UTC) #35
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/2354783004/160001
4 years, 2 months ago (2016-10-05 17:09:50 UTC) #38
dmazzoni
On 2016/10/05 17:06:42, enne wrote: > Looks like that fix landed, so I'll land this ...
4 years, 2 months ago (2016-10-05 18:00:37 UTC) #39
commit-bot: I haz the power
Committed patchset #9 (id:160001)
4 years, 2 months ago (2016-10-05 19:10:55 UTC) #40
commit-bot: I haz the power
4 years, 2 months ago (2016-10-05 19:13:30 UTC) #42
Message was sent while issue was closed.
Patchset 9 (id:??) landed as
https://crrev.com/8c14bf7d37bec879a5caa162f2c72a303da1a6e0
Cr-Commit-Position: refs/heads/master@{#423243}

Powered by Google App Engine
This is Rietveld 408576698