Use safe arithmetic in CFX_PSRenderer::DrawDIBits() [pdfium : main]

0 views
Skip to first unread message

Tom Sepez (Gerrit)

unread,
Apr 6, 2026, 2:24:00 PM (5 days ago) Apr 6
to Lei Zhang, Pdfium LUCI CQ, pdfium-...@googlegroups.com
Attention needed from Lei Zhang

New activity on the change

Open in Gerrit

Related details

Attention is currently required from:
  • Lei Zhang
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: pdfium
Gerrit-Branch: main
Gerrit-Change-Id: Ie521629d06ba944f610b941a8c9e9505fa29aea7
Gerrit-Change-Number: 145731
Gerrit-PatchSet: 3
Gerrit-Owner: Tom Sepez <tse...@chromium.org>
Gerrit-Reviewer: Lei Zhang <the...@chromium.org>
Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
Gerrit-Attention: Lei Zhang <the...@chromium.org>
Gerrit-Comment-Date: Mon, 06 Apr 2026 18:23:58 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Lei Zhang (Gerrit)

unread,
Apr 6, 2026, 4:41:32 PM (5 days ago) Apr 6
to Tom Sepez, Lei Zhang, Pdfium LUCI CQ, pdfium-...@googlegroups.com
Attention needed from Tom Sepez

Lei Zhang added 2 comments

File core/fxge/win32/cfx_psrenderer.cpp
Line 623, Patchset 3 (Latest): FX_SAFE_UINT32 safe_pitch = bytes_per_pixel;
Lei Zhang . unresolved

Pre-existing: I wonder if this should just use `bitmap->GetPitch()` instead.

Line 627, Patchset 3 (Latest): if (!safe_output_size.IsValid()) {
Lei Zhang . unresolved

And if `bitmap` has valid dimensions and pitch, then will this ever fail?

Open in Gerrit

Related details

Attention is currently required from:
  • Tom Sepez
Submit Requirements:
    • requirement satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: pdfium
    Gerrit-Branch: main
    Gerrit-Change-Id: Ie521629d06ba944f610b941a8c9e9505fa29aea7
    Gerrit-Change-Number: 145731
    Gerrit-PatchSet: 3
    Gerrit-Owner: Tom Sepez <tse...@chromium.org>
    Gerrit-Reviewer: Lei Zhang <the...@chromium.org>
    Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
    Gerrit-Attention: Tom Sepez <tse...@chromium.org>
    Gerrit-Comment-Date: Mon, 06 Apr 2026 20:41:29 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Tom Sepez (Gerrit)

    unread,
    Apr 6, 2026, 4:53:01 PM (5 days ago) Apr 6
    to Lei Zhang, Pdfium LUCI CQ, pdfium-...@googlegroups.com
    Attention needed from Lei Zhang

    Tom Sepez added 2 comments

    File core/fxge/win32/cfx_psrenderer.cpp
    Line 623, Patchset 3 (Latest): FX_SAFE_UINT32 safe_pitch = bytes_per_pixel;
    Lei Zhang . unresolved

    Pre-existing: I wonder if this should just use `bitmap->GetPitch()` instead.

    Tom Sepez

    Acknowledged

    Line 627, Patchset 3 (Latest): if (!safe_output_size.IsValid()) {
    Lei Zhang . resolved

    And if `bitmap` has valid dimensions and pitch, then will this ever fail?

    Tom Sepez

    See linked issue for discussion.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Lei Zhang
    Submit Requirements:
    • requirement satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: pdfium
    Gerrit-Branch: main
    Gerrit-Change-Id: Ie521629d06ba944f610b941a8c9e9505fa29aea7
    Gerrit-Change-Number: 145731
    Gerrit-PatchSet: 3
    Gerrit-Owner: Tom Sepez <tse...@chromium.org>
    Gerrit-Reviewer: Lei Zhang <the...@chromium.org>
    Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
    Gerrit-Attention: Lei Zhang <the...@chromium.org>
    Gerrit-Comment-Date: Mon, 06 Apr 2026 20:52:57 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Lei Zhang <the...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Tom Sepez (Gerrit)

    unread,
    Apr 6, 2026, 5:07:37 PM (5 days ago) Apr 6
    to Lei Zhang, Pdfium LUCI CQ, pdfium-...@googlegroups.com
    Attention needed from Lei Zhang

    Tom Sepez added 1 comment

    File core/fxge/win32/cfx_psrenderer.cpp
    Line 623, Patchset 3 (Latest): FX_SAFE_UINT32 safe_pitch = bytes_per_pixel;
    Lei Zhang . resolved

    Pre-existing: I wonder if this should just use `bitmap->GetPitch()` instead.

    Tom Sepez

    Acknowledged

    Tom Sepez

    Acknowledged

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Lei Zhang
    Submit Requirements:
      • requirement satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: pdfium
      Gerrit-Branch: main
      Gerrit-Change-Id: Ie521629d06ba944f610b941a8c9e9505fa29aea7
      Gerrit-Change-Number: 145731
      Gerrit-PatchSet: 3
      Gerrit-Owner: Tom Sepez <tse...@chromium.org>
      Gerrit-Reviewer: Lei Zhang <the...@chromium.org>
      Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
      Gerrit-Attention: Lei Zhang <the...@chromium.org>
      Gerrit-Comment-Date: Mon, 06 Apr 2026 21:07:34 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Lei Zhang <the...@chromium.org>
      Comment-In-Reply-To: Tom Sepez <tse...@chromium.org>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Tom Sepez (Gerrit)

      unread,
      Apr 7, 2026, 12:40:47 PM (4 days ago) Apr 7
      to Lei Zhang, Pdfium LUCI CQ, pdfium-...@googlegroups.com
      Attention needed from Lei Zhang

      Tom Sepez added 1 comment

      Patchset-level comments
      Open in Gerrit

      Related details

      Attention is currently required from:
      • Lei Zhang
      Submit Requirements:
      • requirement satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: pdfium
      Gerrit-Branch: main
      Gerrit-Change-Id: Ie521629d06ba944f610b941a8c9e9505fa29aea7
      Gerrit-Change-Number: 145731
      Gerrit-PatchSet: 3
      Gerrit-Owner: Tom Sepez <tse...@chromium.org>
      Gerrit-Reviewer: Lei Zhang <the...@chromium.org>
      Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
      Gerrit-Attention: Lei Zhang <the...@chromium.org>
      Gerrit-Comment-Date: Tue, 07 Apr 2026 16:40:43 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Lei Zhang (Gerrit)

      unread,
      Apr 7, 2026, 5:44:12 PM (4 days ago) Apr 7
      to Tom Sepez, Lei Zhang, Pdfium LUCI CQ, pdfium-...@googlegroups.com
      Attention needed from Tom Sepez

      Lei Zhang voted and added 2 comments

      Votes added by Lei Zhang

      Code-Review+1

      2 comments

      File core/fxge/win32/cfx_psrenderer.cpp
      Line 623, Patchset 3 (Latest): FX_SAFE_UINT32 safe_pitch = bytes_per_pixel;
      Lei Zhang . resolved

      Pre-existing: I wonder if this should just use `bitmap->GetPitch()` instead.

      Tom Sepez

      Acknowledged

      Tom Sepez

      Acknowledged

      Lei Zhang

      My other idea is to use `bitmap->GetPitch()` and `bitmap->GetBuffer().size()` to get `src_pitch` and `output_size`, respectively.

      Line 627, Patchset 3 (Latest): if (!safe_output_size.IsValid()) {
      Lei Zhang . resolved

      And if `bitmap` has valid dimensions and pitch, then will this ever fail?

      Tom Sepez

      See linked issue for discussion.

      Lei Zhang

      Oh, I guess it's because it's using int here instead of uint32_t. I guess we might as well go with FX_SAFE_UINT32.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Tom Sepez
      Submit Requirements:
      • requirement satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: pdfium
      Gerrit-Branch: main
      Gerrit-Change-Id: Ie521629d06ba944f610b941a8c9e9505fa29aea7
      Gerrit-Change-Number: 145731
      Gerrit-PatchSet: 3
      Gerrit-Owner: Tom Sepez <tse...@chromium.org>
      Gerrit-Reviewer: Lei Zhang <the...@chromium.org>
      Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
      Gerrit-Attention: Tom Sepez <tse...@chromium.org>
      Gerrit-Comment-Date: Tue, 07 Apr 2026 21:44:09 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      open
      diffy

      Tom Sepez (Gerrit)

      unread,
      Apr 7, 2026, 5:44:53 PM (4 days ago) Apr 7
      to Lei Zhang, Pdfium LUCI CQ, pdfium-...@googlegroups.com

      Tom Sepez voted Commit-Queue+2

      Commit-Queue+2
      Open in Gerrit

      Related details

      Attention set is empty
      Submit Requirements:
      • requirement satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: pdfium
      Gerrit-Branch: main
      Gerrit-Change-Id: Ie521629d06ba944f610b941a8c9e9505fa29aea7
      Gerrit-Change-Number: 145731
      Gerrit-PatchSet: 3
      Gerrit-Owner: Tom Sepez <tse...@chromium.org>
      Gerrit-Reviewer: Lei Zhang <the...@chromium.org>
      Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
      Gerrit-Comment-Date: Tue, 07 Apr 2026 21:44:48 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      open
      diffy

      Pdfium LUCI CQ (Gerrit)

      unread,
      Apr 7, 2026, 6:50:33 PM (4 days ago) Apr 7
      to Tom Sepez, Lei Zhang, pdfium-...@googlegroups.com

      Pdfium LUCI CQ submitted the change

      Change information

      Commit message:
      Use safe arithmetic in CFX_PSRenderer::DrawDIBits()

      Hardening suggestion from the AI bot.
      Bug: 500036290
      Change-Id: Ie521629d06ba944f610b941a8c9e9505fa29aea7
      Reviewed-by: Lei Zhang <the...@chromium.org>
      Commit-Queue: Tom Sepez <tse...@chromium.org>
      Files:
      • M core/fxge/win32/cfx_psrenderer.cpp
      Change size: S
      Delta: 1 file changed, 10 insertions(+), 2 deletions(-)
      Branch: refs/heads/main
      Submit Requirements:
      • requirement satisfiedCode-Review: +1 by Lei Zhang
      Open in Gerrit
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: merged
      Gerrit-Project: pdfium
      Gerrit-Branch: main
      Gerrit-Change-Id: Ie521629d06ba944f610b941a8c9e9505fa29aea7
      Gerrit-Change-Number: 145731
      Gerrit-PatchSet: 4
      Gerrit-Owner: Tom Sepez <tse...@chromium.org>
      Gerrit-Reviewer: Lei Zhang <the...@chromium.org>
      Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
      open
      diffy
      satisfied_requirement
      Reply all
      Reply to author
      Forward
      0 new messages