Skip to content

track non-seekable stream size as usize in yyjson_read_fp#284

Merged
ibireme merged 1 commit into
ibireme:masterfrom
dxbjavid:read-fp-stream-size-overflow
Jun 19, 2026
Merged

track non-seekable stream size as usize in yyjson_read_fp#284
ibireme merged 1 commit into
ibireme:masterfrom
dxbjavid:read-fp-stream-size-overflow

Conversation

@dxbjavid

Copy link
Copy Markdown
Contributor

yyjson_read_fp keeps the running byte count of a non-seekable stream in a signed long, while the buffer length itself is a usize that is overflow-checked as it grows. on builds where long is narrower than size_t (LLP64, and 32-bit targets) a stream larger than LONG_MAX wraps that counter negative, so the trailing memset writes before the buffer and yyjson_read_opts is handed a bogus length, reading and writing out of bounds. track the byte count in a usize alongside buf_size so it cannot overflow before the already-guarded buffer length does.

@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 98.55%. Comparing base (1d3f49c) to head (83d594f).

Files with missing lines Patch % Lines
src/yyjson.c 85.71% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master     #284   +/-   ##
=======================================
  Coverage   98.55%   98.55%           
=======================================
  Files           2        2           
  Lines        7726     7728    +2     
=======================================
+ Hits         7614     7616    +2     
  Misses        112      112           
Flag Coverage Δ
unittests 98.55% <85.71%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ibireme ibireme merged commit 92ae1e2 into ibireme:master Jun 19, 2026
45 of 46 checks passed
@dxbjavid

Copy link
Copy Markdown
Contributor Author

Thank you for the review and merge. Appreciated

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