fix off-by-one write copying snmp supply names#1604
Closed
aizu-m wants to merge 1 commit into
Closed
Conversation
The unknown character set branch in backend_walk_cb copies prtMarkerSuppliesDescription into supplies[i-1].name until the source nul. object_value.string.bytes is CUPS_SNMP_MAX_STRING + 1 bytes while name is CUPS_SNMP_MAX_STRING, so a 1024-byte description writes the terminating nul one past name. Bound the copy like the other charset branches do.
michaelrsweet
requested changes
Jun 9, 2026
michaelrsweet
left a comment
Member
There was a problem hiding this comment.
We should just change the supply level name buffer to be size+1 as well.
michaelrsweet
added a commit
that referenced
this pull request
Jun 9, 2026
michaelrsweet
added a commit
that referenced
this pull request
Jun 9, 2026
Member
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.
Checking the SNMP backend supply parser. The unknown-charset branch in backend_walk_cb carries a comment that the copy is safe because both buffers are CUPS_SNMP_MAX_STRING long. They are not:
asn1_get_string can fill the source with 1024 non-nul bytes. A printer that reports an unknown character set and a 1024-byte prtMarkerSuppliesDescription then makes the loop copy 1024 chars and write the terminating nul one past name. Reproduced the exact loop with a canary:
The other charset branches pass sizeof(supplies[0].name) and stay inside the buffer. Bounding the loop the same way keeps the nul in range.