Skip to content

reject out-of-range nanoseconds in msgpack_object_to_timestamp - #1233

Open
rajath201 wants to merge 1 commit into
msgpack:c_masterfrom
rajath201:c-timestamp-nsec-range
Open

rajath201 wants to merge 1 commit into
msgpack:c_masterfrom
rajath201:c-timestamp-nsec-range

Conversation

@rajath201

Copy link
Copy Markdown

msgpack_object_to_timestamp (include/msgpack/timestamp.h) returns true for a timestamp64/96 whose nanoseconds field is above the spec's 999999999. c7 0c ff ff ff ff ff ff ff ff ff ff ff ff ff (sec -1, nsec 0xffffffff) decodes to tv_nsec = 4294967295, which becomes -1 once copied into a struct timespec with a 32-bit long, and passing the result back to msgpack_pack_timestamp silently drops the top bits of any nsec at or above 2^30, since the timestamp64 path shifts tv_nsec left by 34.

Return false for those values, the result the function already gives for a malformed timestamp ext, and leave ts untouched in that case. This is the c_master half of #1227, which added the same check to the C++ timespec/chrono adaptors and can't reach the C library; the new timestamp_nsec_out_of_range test fails on the current tree and passes with the fix, and the C suite stays green under ASan.

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.73%. Comparing base (eabfe29) to head (121b3b5).
⚠️ Report is 29 commits behind head on c_master.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff              @@
##           c_master    #1233      +/-   ##
============================================
+ Coverage     57.47%   63.73%   +6.26%     
============================================
  Files            10       10              
  Lines          1124     1150      +26     
  Branches        129      142      +13     
============================================
+ Hits            646      733      +87     
+ Misses          478      417      -61     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants