Repository navigation
fix integer overflow in pwg_scan_measurement - #176
Open
tanjiroK-coder wants to merge 1 commit into
Open
tanjiroK-coder wants to merge 1 commit into
tanjiroK-coder wants to merge 1 commit into
Conversation
The digit loop accumulates into an int and the final conversion multiplies by up to 100000, so an over-large media size name decodes to a negative width and length instead of a clamped value.
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
pwg_scan_measurementaccumulates into anint, so a name with ten or more digits wraps:pwgMediaForPWG("custom_max_9999999999x9999999999mm")gives width and length of -727380068.value * numeroverflows on its own for much shorter names sincenumeris up to 100000 for metres:custom_max_1000000x1000000ingives -1754967296.Both accumulators are
long longnow and the return saturates atINT_MAX, so valid names decode exactly as before. The size name is remote input, it comes in onmedia-supported/media-readyand reaches here viacupsCheckDestSupportedandcupsGetDestMediaByName, where a negative width then defeats the custom-size range check. Turned up running-fsanitize=undefinedover the media name parsers, which fires atpwg-media.c:1065and:1086; the twotestpwgcases fail on master and pass with the change.Assisted-by: Claude Code:claude-opus-5