Bound queue-name handling to fix stack overflow (OCU-01-015) - #73
Open
AayushKumar26 wants to merge 1 commit into
Open
Bound queue-name handling to fix stack overflow (OCU-01-015)#73AayushKumar26 wants to merge 1 commit into
AayushKumar26 wants to merge 1 commit into
Conversation
get_cluster_attributes() built "Cluster " + cluster_name into a fixed char[256] with strcpy/strcat. A discovery-derived queue name longer than 247 bytes overflowed the buffer. Use snprintf, and cap generated queue names to 127 characters (the limit CUPS enforces in validate_name()) in get_local_queue_name(), so oversized discovery names can't reach fixed buffers while every CUPS-valid name still works. Fixes OpenPrinting#72
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.
What this fixes
Fixes #72 (audit finding OCU-01-015).
get_cluster_attributes()builds"Cluster " + cluster_nameinto a fixedchar[256]withstrcpy/strcat. The queue name comes from network discovery data, so a name longer than 247 bytes overflows the stack buffer during clustered queue generation.The changes
get_cluster_attributes()usessnprintfinstead ofstrcpy/strcat, so the make/model string can't overflow.get_local_queue_name()caps the generated queue name at 127 characters. That's the limit CUPS itself enforces;validate_name()in the CUPS scheduler requires the length to be < 128 ; so any name CUPS would accept still passes, and oversized discovery-derived names are bounded before they reach any fixed buffer. The cap is applied where the name is generated, not inremove_bad_chars(), which stays character-only.