bound literal copy in win32 cupsDNSSDAssembleFullName - #170
Closed
tanjiroK-coder wants to merge 1 commit into
Closed
tanjiroK-coder wants to merge 1 commit into
tanjiroK-coder wants to merge 1 commit into
Conversation
michaelrsweet
added a commit
that referenced
this pull request
Sep 29, 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.
reading through the win32 branch of
cupsDNSSDAssembleFullNameincups/dnssd.ci noticed the loop that copies the service instance name into the caller-providedfullnamebuffer only stops at the end of the source string. the branch that escapes spaces, backslashes and high-bit bytes checks(fullend - fullptr) < 4before writing, but the plain literal-copyelsebranch does*fullptr++ = *namewith no room check and theforitself carries nofullptr < fullendbound, so anamelonger thanfullsizewalks off the end of the buffer. the helper takesfullsizeprecisely so it can keep its output inside the buffer, so this is the assembler overrunning the caller rather than caller misuse. the mDNSResponder and Avahi builds route throughDNSServiceConstructFullName/avahi_service_name_joinand are unaffected; only the hand-rolled Windows path is exposed. i added the samefullptr >= fullendguard the escape branch already uses so an over-long name fails cleanly instead of overwriting memory. checked with a small ASan harness over the extracted loop: a 500-byte name overruns a 64-byte buffer before the change and returns false after.