Skip to content

Bound queue-name handling to fix stack overflow (OCU-01-015) - #73

Open
AayushKumar26 wants to merge 1 commit into
OpenPrinting:masterfrom
AayushKumar26:fix/ocu-01-015-queue-name-overflow
Open

Bound queue-name handling to fix stack overflow (OCU-01-015)#73
AayushKumar26 wants to merge 1 commit into
OpenPrinting:masterfrom
AayushKumar26:fix/ocu-01-015-queue-name-overflow

Conversation

@AayushKumar26

Copy link
Copy Markdown
Contributor

What this fixes

Fixes #72 (audit finding OCU-01-015).

get_cluster_attributes() builds "Cluster " + cluster_name into a fixed char[256] with strcpy/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() uses snprintf instead of strcpy/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 in remove_bad_chars(), which stays character-only.

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
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

Successfully merging this pull request may close these issues.

OCU-01-015 WP3: Stack Overflow via Discovery-Derived Queue Names (High)

1 participant