fix out-of-bounds write in cups_collection_string#1631
Merged
michaelrsweet merged 1 commit intoJun 25, 2026
Conversation
The serialiser advances bufptr past bufend to report the length needed, so the final *bufptr = '\0' could terminate out of bounds once a collection overflows the buffer. Clamp it the way ippAttributeString already does, and keep the bufsize==0 sub-collection call safe.
michaelrsweet
approved these changes
Jun 25, 2026
Member
|
Also pushed the fix to 2.4.x: [2.4.x 421e067b2] Fix potential buffer overflow in cupsCopyDestConflicts (Issue #1631) |
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.
AddressSanitizer, exercising cupsCopyDestConflicts() against a printer that answers Get-Printer-Attributes with an oversized media-col-default:
cups_collection_string() advances bufptr even when there is no room, so it can report the length needed, but the closing *bufptr = '\0' is the one write that never checks bufend. cups_create_defaults() calls it with a 2048-byte stack buffer for every *-default collection attribute, and those attributes come straight off the wire through cupsCopyDestInfo2(). A printer returning a collection that serialises past 2048 bytes therefore drops a nul a content-controlled distance past the buffer. The length check in the caller only runs after the write.
ippAttributeString() guards the same terminator already. This matches it, and keeps the bufsize==0 sub-collection call at line 2005 safe.