Skip to content
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

Image.alphaBlend has an overrun error when fgStride is greater than type(uint8).max #92

Open
wattsyart opened this issue Aug 9, 2023 · 0 comments

Comments

@wattsyart
Copy link

wattsyart commented Aug 9, 2023

The first line of function alphaBlend(bytes memory backBgr, bytes memory foreAbgr, uint256 width, Rectangle memory rect) has a flaw, where the fgStride calculation will revert because Rectangle uses uint8, and xMin and xMax, when multiplied together, could be larger than a uint8.

For example, if xMax is 64, and xMin is 64, multiplication would overrun since the value will equal 256.

This line:

uint256 fgStride = (rect.xMax - rect.xMin) * 4;

Should be:

uint256 fgStride = uint256(rect.xMax - rect.xMin) * 4; 
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

No branches or pull requests

1 participant