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

Issue 2454293004: Printing: Fix undefined behavior for near 0 scaling (Closed)

Created:
4 years, 1 month ago by rbpotter
Modified:
4 years, 1 month ago
Reviewers:
Lei Zhang
CC:
chromium-reviews, mac-reviews_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Printing: Fix undefined behavior for near 0 scaling. Sometimes casting 0 integer value to a float results in a very small number (on the order of 1e-312). This results in integer overflows when this scaling is used. Check scaling against 0.01f instead of 0 since we know it has to be an integer/100. If it is less than .01 the value must have been 0 (not set), so set it to the default value (1.0). Undefined behavior was introduced in: https://crrev.com/427556 BUG=660135 Committed: https://crrev.com/2f5080ac8257bc1dacb6045bdf2d2a3fedb95531 Cr-Commit-Position: refs/heads/master@{#428597}

Patch Set 1 #

Total comments: 2

Patch Set 2 : Add constant #

Total comments: 2

Patch Set 3 : Move declaration #

Total comments: 2

Patch Set 4 : Fix declaration #

Unified diffs Side-by-side diffs Delta from patch set Stats (+12 lines, -5 lines) Patch
M components/printing/renderer/print_web_view_helper.h View 1 2 3 1 chunk +5 lines, -0 lines 0 comments Download
M components/printing/renderer/print_web_view_helper.cc View 1 2 3 4 chunks +5 lines, -4 lines 0 comments Download
M components/printing/renderer/print_web_view_helper_mac.mm View 1 3 1 chunk +2 lines, -1 line 0 comments Download

Messages

Total messages: 29 (19 generated)
rbpotter
4 years, 1 month ago (2016-10-29 00:09:15 UTC) #7
Lei Zhang
BTW, in the commit message, https://crrev.com/427556 is equivalent and more human readable. https://codereview.chromium.org/2454293004/diff/1/components/printing/renderer/print_web_view_helper.cc File components/printing/renderer/print_web_view_helper.cc ...
4 years, 1 month ago (2016-10-29 00:26:53 UTC) #8
rbpotter
https://codereview.chromium.org/2454293004/diff/1/components/printing/renderer/print_web_view_helper.cc File components/printing/renderer/print_web_view_helper.cc (right): https://codereview.chromium.org/2454293004/diff/1/components/printing/renderer/print_web_view_helper.cc#newcode237 components/printing/renderer/print_web_view_helper.cc:237: if (scale_factor >= 0.01f && (fit_to_page || params.print_to_pdf)) { ...
4 years, 1 month ago (2016-10-29 00:41:53 UTC) #12
Lei Zhang
https://codereview.chromium.org/2454293004/diff/20001/components/printing/renderer/print_web_view_helper.h File components/printing/renderer/print_web_view_helper.h (right): https://codereview.chromium.org/2454293004/diff/20001/components/printing/renderer/print_web_view_helper.h#newcode54 components/printing/renderer/print_web_view_helper.h:54: constexpr double kEpsilon = .01f; Mmm, this adds printing::kEpsilon. ...
4 years, 1 month ago (2016-10-29 00:59:27 UTC) #13
rbpotter
https://codereview.chromium.org/2454293004/diff/20001/components/printing/renderer/print_web_view_helper.h File components/printing/renderer/print_web_view_helper.h (right): https://codereview.chromium.org/2454293004/diff/20001/components/printing/renderer/print_web_view_helper.h#newcode54 components/printing/renderer/print_web_view_helper.h:54: constexpr double kEpsilon = .01f; On 2016/10/29 00:59:27, Lei ...
4 years, 1 month ago (2016-10-29 01:09:38 UTC) #15
Lei Zhang
lgtm with one more round of shuffling. https://codereview.chromium.org/2454293004/diff/40001/components/printing/renderer/print_web_view_helper.cc File components/printing/renderer/print_web_view_helper.cc (right): https://codereview.chromium.org/2454293004/diff/40001/components/printing/renderer/print_web_view_helper.cc#newcode117 components/printing/renderer/print_web_view_helper.cc:117: constexpr double ...
4 years, 1 month ago (2016-10-29 01:19:25 UTC) #17
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/2454293004/60001
4 years, 1 month ago (2016-10-29 04:18:09 UTC) #24
commit-bot: I haz the power
Committed patchset #4 (id:60001)
4 years, 1 month ago (2016-10-29 04:22:56 UTC) #26
commit-bot: I haz the power
Patchset 4 (id:??) landed as https://crrev.com/2f5080ac8257bc1dacb6045bdf2d2a3fedb95531 Cr-Commit-Position: refs/heads/master@{#428597}
4 years, 1 month ago (2016-10-29 04:24:45 UTC) #28
rbpotter
4 years, 1 month ago (2016-10-31 16:30:24 UTC) #29
Message was sent while issue was closed.
https://codereview.chromium.org/2454293004/diff/40001/components/printing/ren...
File components/printing/renderer/print_web_view_helper.cc (right):

https://codereview.chromium.org/2454293004/diff/40001/components/printing/ren...
components/printing/renderer/print_web_view_helper.cc:117: constexpr double
kEpsilon = 0.01f;
On 2016/10/29 01:19:24, Lei Zhang wrote:
> Sorry, I meant line 115 in the header file, that way you can still use the
> constant in print_web_view_helper_mac.mm.
> 
> CalculatePageLayoutFromPrintParams() will have to change to refer to it as
> PrintWebViewHelper::kEpsilon.

Done.

Powered by Google App Engine
This is Rietveld 408576698