Repository navigation
fix heap overflow in cupsJSONExportString for non-root nodes - #187
Merged
michaelrsweet merged 1 commit intoOct 22, 2026
Merged
Conversation
michaelrsweet
approved these changes
Oct 22, 2026
michaelrsweet
left a comment
Member
There was a problem hiding this comment.
Looks good. In the future, just put the changelog in the description and I'll manually add it. Thanks!
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.
cupsJSONExportString sizes its output in one pass over the tree and writes it in a second pass, but neither pass stops at the node it was given. When that node has a parent, both walks emit a leading ':' or ',', follow its siblings and climb into the ancestors, and only the write pass adds a closing ']' or '}' for each ancestor it climbs through, so the malloc'd string is overrun by one byte per enclosing level. cups-oauth hits this with server-supplied data:
get-metadata URI NAMEandget-user-id URI NAMEexport the value of NAME directly when it is an object or array, and the metadata and ID token claims both come from the remote server, so its nesting depth decides how far the write goes. Exporting "a" from{"a":{"b":{"c":{"d":{"e":[1]}}}},"z":2}gives an ASan heap-buffer-overflow WRITE at json.c:476, and even without the overflow the result carries a stray ':' and the following "z" member. Both passes now treat the exported node as the root of the walk, so nothing outside it is visited; output for a root node is unchanged. The new testjson case exports a child object and checks the string; it fails under ASan on master and passes with the fix, andmake testis green.