-
Notifications
You must be signed in to change notification settings - Fork 272
Fix potential integer overflow in rowBytes multiplications #3053
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
wantehchang
merged 5 commits into
AOMediaCodec:main
from
rootvector2:fix/rowbytes-integer-overflow-audit
Feb 25, 2026
+97
−75
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
60f7cba
Fix potential integer overflow in rowBytes multiplications
rootvector2 5bf8fa2
prevent potential size_t overflow in UV plane size calculations
rootvector2 dc8d99c
conversion warnings in codec_svt.c
rootvector2 8ea8f53
overflow checks and size_t casts
rootvector2 d2ea079
undo the changes to these four lines
rootvector2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1209,8 +1209,8 @@ static avifResult aomCodecEncodeImage(avifCodec * codec, | |
| if (aomImageAllocated) { | ||
| const uint32_t bytesPerRow = ((image->depth > 8) ? 2 : 1) * image->width; | ||
| for (uint32_t j = 0; j < image->height; ++j) { | ||
| const uint8_t * srcAlphaRow = &image->alphaPlane[j * image->alphaRowBytes]; | ||
| uint8_t * dstAlphaRow = &aomImage.planes[0][j * aomImage.stride[0]]; | ||
| const uint8_t * srcAlphaRow = &image->alphaPlane[(size_t)j * image->alphaRowBytes]; | ||
| uint8_t * dstAlphaRow = &aomImage.planes[0][(size_t)j * aomImage.stride[0]]; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dexter.k: For future reference: This for loop could be also be rewritten as follows, which avoids multiplying |
||
| memcpy(dstAlphaRow, srcAlphaRow, bytesPerRow); | ||
| } | ||
| } else { | ||
|
|
@@ -1233,8 +1233,8 @@ static avifResult aomCodecEncodeImage(avifCodec * codec, | |
| uint32_t bytesPerRow = bytesPerPixel * planeWidth; | ||
|
|
||
| for (uint32_t j = 0; j < planeHeight; ++j) { | ||
| const uint8_t * srcRow = &image->yuvPlanes[yuvPlane][j * image->yuvRowBytes[yuvPlane]]; | ||
| uint8_t * dstRow = &aomImage.planes[yuvPlane][j * aomImage.stride[yuvPlane]]; | ||
| const uint8_t * srcRow = &image->yuvPlanes[yuvPlane][(size_t)j * image->yuvRowBytes[yuvPlane]]; | ||
wantehchang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| uint8_t * dstRow = &aomImage.planes[yuvPlane][(size_t)j * aomImage.stride[yuvPlane]]; | ||
| memcpy(dstRow, srcRow, bytesPerRow); | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.