guard uninitialized count from descr sscanf in npy parser#9222
Open
soma0212 wants to merge 1 commit into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9222 +/- ##
=======================================
Coverage ? 69.79%
=======================================
Files ? 255
Lines ? 78885
Branches ? 18859
=======================================
Hits ? 55054
Misses ? 18275
Partials ? 5556 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
alexreinking
approved these changes
Jul 19, 2026
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