fix heap over-read in cupsLangLoadStrings on trailing ';' - #171
Closed
tanjiroK-coder wants to merge 2 commits into
Closed
tanjiroK-coder wants to merge 2 commits into
tanjiroK-coder wants to merge 2 commits into
Conversation
the loop already advances past the ';' via its own dataptr++, so the extra explicit skip stepped a second time and walked one byte past the malloc'd buffer when ';' was the last byte. it also dropped an entry when two pairs had no separator between them.
michaelrsweet
requested changes
Sep 30, 2026
michaelrsweet
left a comment
Member
There was a problem hiding this comment.
Not going to amend the unit test for this...
Investigating...
the maintainer doesn't want the unit test amended for this, so the PR is now just the one-line fix in language.c plus the CHANGES entry.
Contributor
Author
|
fair enough, dropped the if it helps while you're looking: any |
michaelrsweet
added a commit
that referenced
this pull request
Oct 2, 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.
heap over-read in
cupsLangLoadStringson a trailing;reading the
.stringsparser i noticed the entry loop skips the;with an explicitdataptr ++and then the enclosingfor (... ; *dataptr ; dataptr ++)steps past it a second time, so one byte after the;is consumed without ever being looked at. when;is the last byte of the catalog the explicit advance lands on the NUL and the loop increment then moves one past themalloc(st_size + 1)buffer, so*dataptrreads out of bounds and parsing runs on into adjacent heap until it trips over a NUL or a syntax error.it is reachable from an untrusted printer:
cups_load_localizationsindest-localization.cdownloads the printer'sprinter-strings-urito a temp file and hands it tocupsLangLoadStrings, and the in-memorycupsLangAddStringspath is exposed the same way. dropped the redundant advance so the loop increment alone consumes the;; that also fixes a line-number off-by-one and a spurious syntax error when two pairs sit next to each other with no separator.verified with a standalone asan reproducer: a
;-terminated buffer reportsheap-buffer-overflowatlanguage.c:326before the change and loads cleanly after.testlangis green with the fix.Assisted-by: Claude:claude-opus-4-8 [Claude Code]