Repository navigation
Fix #941: empty strings break msgpack_object_print_buffer() (C) - #942
Merged
Merged
Conversation
Don't abort serialization when running into empty strings in msgpack_object_print_buffer(). Added a couple of unit tests to test empty string cases.
Use sprintf_s (windows) or snprintf (others) instead of sprintf in unit tests.
Contributor
|
Thank you for sending the PR. |
trestoncuzzort
added a commit
to trestoncuzzort/dawnr
that referenced
this pull request
Nov 6, 2026
msgpack_object_print_buffer (msgpack-c src/objectc.c at 319ae6ed, branch c_master) prints a BIN or an EXT object through msgpack_object_bin_print_buffer, and the MSGPACK_CHECKED_CALL macro takes a result of 0 as a failure. An object without bytes gives 0 there, so the function returns 0 after the opening quote. The STR branch has had a guard for the empty string since 2021; the case checks the same guard on the BIN and EXT branches. The harness prints a BIN object or an EXT object of every type, with zero to two bytes of every value, into every buffer size from 0 to 24, and compares the result, the text, the bytes after the given size and the terminator with the text that msgpack_object_print() writes. The model reads snprintf and isprint as stand-ins in the prelude; the replay of a counterexample calls the C library. Suite run of 2026-11-06 with CBMC 6.11.0, in suite-2026-11-06.json: the original fails with one replayed witness (a BIN object without bytes into 19 bytes), the proposed change completes on 445 properties, and contradictory assumptions and an unwinding bound of 1 are vacuous. cross_check.py is outside the gate. With GCC 13.3 and glibc 2.39 the stand-ins agree with the C library in 19506 comparisons, and of the 422720025 inputs of the domain the original fails 3184, all of them objects without bytes, and the proposed change none. Sources: https://github.com/msgpack/msgpack-c/blob/319ae6edf016327738b707cdb0d222b6091ae9f2/src/objectc.c; https://github.com/msgpack/msgpack-c/blob/319ae6edf016327738b707cdb0d222b6091ae9f2/include/msgpack/object.h; msgpack/msgpack-c#942; C11 7.21.6.5 (snprintf) and 7.4.1.8 (isprint), https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf
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.
Don't abort serialization when running into empty strings in msgpack_object_print_buffer().
Added a couple of unit tests to test empty string cases.