guard uninitialized count from descr sscanf in npy parser - #9222
Open
soma0212 wants to merge 2 commits into
Open
guard uninitialized count from descr sscanf in npy parser#9222soma0212 wants to merge 2 commits into
soma0212 wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9222 +/- ##
==========================================
+ Coverage 69.92% 70.27% +0.34%
==========================================
Files 255 255
Lines 78895 78895
Branches 18865 18865
==========================================
+ Hits 55166 55441 +275
+ Misses 17928 17822 -106
+ Partials 5801 5632 -169 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
alexreinking
approved these changes
Jul 19, 2026
Member
|
@soma0212 — Can you please rebase on main? |
soma0212
force-pushed
the
npy-header-uninit-count
branch
from
July 28, 2026 05:35
cf223c2 to
a9580ac
Compare
Contributor
Author
|
Done, rebased on main. Only conflict was in image_io.cpp against the new read_big_endian_row test; kept both. |
soma0212
force-pushed
the
npy-header-uninit-count
branch
from
July 28, 2026 05:37
a9580ac to
27e3f7d
Compare
Contributor
Author
|
Done, rebased on main. Only conflict was the new read_big_endian_row test landing in the same spot in image_io.cpp; kept both. |
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.
load_npywalks a raw cursor through the header dict, and one sscanf can leave that cursor undefined:'descr'scan reads%c%c%dthen a literal closing quote, and only the trailing%nwrites the byte count, but%nis not part of sscanf's return valueconsumedstays uninitialized andptr += consumedjumps by a garbage offset that the next read dereferencesconsumedand requiring it to be set rejects the malformed dict instead of advancing the cursor into unmapped memoryReachable from any
.npyopened throughload_image; an ASAN build faults insideNpyHeader::parseon a header whose descr drops the quote. Added a regression test that writes such a file and checks the loader returns false.Checklist