Skip to content

webrtc: widen screenshot buffer size and offset arithmetic to size_t - #3628

Merged
adelva1984 merged 1 commit into
google:mainfrom
adelva1984:fix/screenshot-handler-overflow
Nov 19, 2026
Merged

adelva1984 merged 1 commit into
google:mainfrom
adelva1984:fix/screenshot-handler-overflow

Conversation

@adelva1984

Copy link
Copy Markdown
Collaborator

Casts int width/stride/row operands to size_t before multiplication in base/cvd/cuttlefish/host/frontend/webrtc/screenshot_handler.cpp (FrameToRgb, PngScreenshot, and JpegScreenshot).

Resolves the CodeQL cpp/integer-multiplication-cast-to-long alert at screenshot_handler.cpp:45 and related buffer size/offset calculations.

Cast `int` width/stride/row operands to `size_t` before multiplication in `screenshot_handler.cpp` (`FrameToRgb`, `PngScreenshot`, and `JpegScreenshot`).

This resolves the CodeQL `cpp/integer-multiplication-cast-to-long` alert at `screenshot_handler.cpp:45` and related buffer size/offset calculations.

Assisted-by: Jetski:Gemini
@adelva1984

Copy link
Copy Markdown
Collaborator Author

Alternatives considered: use an unsigned type in VideoFrameBuffer subclass, but this ends up not mixing so well with upstream webrtc's lazy use of the int datatype.

@adelva1984
adelva1984 requested review from Databean and jemoreira and removed request for Databean November 18, 2026 21:17
@Databean

Copy link
Copy Markdown
Member

There were some issues using size_t fixed earlier by #3316 but it seems correct here.

More pedantically correct would be std::vector<uint8_t>::size_type since that's the literal parameter type of the constructor, but cppreference already says "usually std::size_t" for that.

@adelva1984
adelva1984 added this pull request to the merge queue Nov 18, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 18, 2026
@adelva1984
adelva1984 added this pull request to the merge queue Nov 18, 2026
Merged via the queue into google:main with commit a7040c0 Nov 19, 2026
76 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants