Skip to content

split long writes across zlib's 32-bit counters in C++ zbuffer - #1235

Open
rajath201 wants to merge 1 commit into
msgpack:cpp_masterfrom
rajath201:cpp-zbuffer-uint-counters
Open

rajath201 wants to merge 1 commit into
msgpack:cpp_masterfrom
rajath201:cpp-zbuffer-uint-counters

Conversation

@rajath201

Copy link
Copy Markdown

Targets cpp_master. zbuffer::write() in include/msgpack/v1/zbuffer.hpp assigns the size_t length straight to zlib's 32-bit avail_in, so on 64-bit targets a write of 4 GiB or more feeds only len mod 2^32 bytes to deflate and returns normally. Compressing a large serialized buffer in one call (zbuf.write(sbuf.data(), sbuf.size()) with 4 GiB + 1 bytes) compresses 1 byte, and the receiver gets a truncated stream with no error on either side. expand() narrows avail_out the same way: with exactly 4 GiB free it becomes 0, so deflate gets no output room (write throws, flush keeps re-expanding to the same size).

Feed zlib in uInt-sized chunks and saturate avail_out, the C++ counterpart of what #1205 did for msgpack_zbuffer_write/msgpack_zbuffer_expand on c_master. The new test/zbuffer_sizes.cpp uses a counting stand-in for deflate() so it needs no 4 GiB buffer; it fails on the current tree (4294967297 != 1) and passes with the fix. The C++11 and C++17 suites pass with g++ 16.2 and -Werror, apart from two existing Windows-only warnings (16-bit wchar_t in msgpack_container, -Wself-move in security_fixes_cpp11) that also fail without this change.

@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

❌ Patch coverage is 93.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 80.06%. Comparing base (39cc081) to head (f88e19e).
⚠️ Report is 52 commits behind head on cpp_master.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@              Coverage Diff               @@
##           cpp_master    #1235      +/-   ##
==============================================
- Coverage       85.36%   80.06%   -5.31%     
==============================================
  Files              80       80              
  Lines            5099     5839     +740     
  Branches          507      645     +138     
==============================================
+ Hits             4353     4675     +322     
- Misses            746     1164     +418     
🚀 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