Repository navigation
plugins types REFACTOR build strings with ly_append_str - #2591
Merged
Merged
Conversation
The bits, identityref, instance-identifier-keys, xpath1.0 and union type plugins grew their strings by computing each realloc() size by hand and then writing into the buffer with sprintf() or strcpy(). Use ly_append_str() instead, which sizes the buffer from the formatted output itself, so no length computation has to be kept in sync with the format string. The IPv4/IPv6 zone suffix is now printed with snprintf() bounded by the allocated size. ly_append_str() now checks for vsnprintf() failure and size overflow and is declared with printf format checking. ly_strcat() checks for vasprintf() failure and no longer leaks on realloc() failure. Printed values and error messages are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
michalvasko
approved these changes
Oct 19, 2026
Member
|
Thanks, looks good. |
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.
The bits, identityref, instance-identifier-keys, xpath1.0 and union type plugins grow strings by summing each realloc() size by hand and then writing with sprintf() or strcpy(). Every one of those sums has to match its format string. This switches them to the existing ly_append_str() helper, which sizes the buffer from the formatted output itself. The IPv4/IPv6 zone suffix is now printed with snprintf() bounded by the allocated size.
ly_append_str() also gains printf format checking and checks for vsnprintf() failure and size overflow. ly_strcat() now checks for vasprintf() failure and does not leak on realloc() failure.
All tests pass, and one new test covers the multi-base identityref error message.
If it lands, we may submit it to Google's Patch Rewards program, and we'd be glad to share any reward with the maintainers.
— ChipLab