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

Issue 2563643002: StringToNumber: Fix integer overflow on parsing INT_MIN. (Closed)

Created:
4 years ago by Yuta Kitamura
Modified:
4 years ago
Reviewers:
haraken, esprehn, tzik
CC:
blink-reviews, blink-reviews-wtf_chromium.org, chromium-reviews, Mikhail
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

StringToNumber: Fix integer overflow on parsing INT_MIN. This patch adjusts the algorithm of toIntegralType(), which parses an integer value out of a string. Previously, toIntegralType() used a positive number as an accumulator regardless of whether we had seen the negative sign or not, and it inverted the accumulator value if there had been a negative sign. This causes an integer overflow when INT_MIN is specified as the source string, because the absolute value of INT_MIN is one larger than that of INT_MAX. This patch fixes this issue by accumulating a negative value if the result will be negative. Also, the detection algorithm of overflows is updated so that it can detect overflows correctly in every possible case (it used to have a small bug that the function fails to parse INT_MIN in base 16). Additionally, unit tests are added. BUG=665110 Committed: https://crrev.com/957b5b3085eeae5a6fd6779d62feb90cc2515ad2 Cr-Commit-Position: refs/heads/master@{#437508}

Patch Set 1 #

Patch Set 2 : Fix MSVC warning. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+154 lines, -19 lines) Patch
M third_party/WebKit/Source/wtf/BUILD.gn View 1 chunk +1 line, -0 lines 0 comments Download
M third_party/WebKit/Source/wtf/text/StringToNumber.cpp View 1 3 chunks +27 lines, -19 lines 0 comments Download
A third_party/WebKit/Source/wtf/text/StringToNumberTest.cpp View 1 chunk +126 lines, -0 lines 0 comments Download

Messages

Total messages: 19 (12 generated)
Yuta Kitamura
PTAL?
4 years ago (2016-12-09 05:52:31 UTC) #8
esprehn
lgtm
4 years ago (2016-12-09 06:33:46 UTC) #9
tzik
lgtm
4 years ago (2016-12-09 06:54:31 UTC) #10
haraken
LGTM
4 years ago (2016-12-09 07:28:41 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/2563643002/20001
4 years ago (2016-12-09 09:49:39 UTC) #15
commit-bot: I haz the power
Committed patchset #2 (id:20001)
4 years ago (2016-12-09 09:53:50 UTC) #17
commit-bot: I haz the power
4 years ago (2016-12-09 09:56:15 UTC) #19
Message was sent while issue was closed.
Patchset 2 (id:??) landed as
https://crrev.com/957b5b3085eeae5a6fd6779d62feb90cc2515ad2
Cr-Commit-Position: refs/heads/master@{#437508}

Powered by Google App Engine
This is Rietveld 408576698