Repository navigation
Validate NPY shape sizes before allocation - #6443
Merged
Merged
Conversation
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
Contributor
|
| Filename | Overview |
|---|---|
| dali/util/numpy.cc | Adds range, dimension, element-count, and byte-count validation to NumPy header processing. |
| dali/util/numpy_test.cc | Adds invalid-shape tests and now directly reaches the byte-count overflow guard while element-count calculation succeeds. |
Reviews (5): Last reviewed commit: "Extract NumPy overflow checks from enfor..." | Re-trigger Greptile
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
Contributor
Author
|
!build |
Collaborator
|
CI MESSAGE: [61556858]: BUILD STARTED |
Collaborator
|
CI MESSAGE: [61556858]: BUILD PASSED |
rostan-t
approved these changes
Aug 10, 2026
banasraf
approved these changes
Aug 10, 2026
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
rostan-t
approved these changes
Aug 11, 2026
Contributor
Author
|
!build |
Collaborator
|
CI MESSAGE: [62108786]: BUILD STARTED |
Collaborator
|
CI MESSAGE: [62108786]: BUILD PASSED |
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.
Category:
Bug fix
Description:
Reject invalid and overflowing NumPy array shapes before an allocation or file read can use a wrapped element or byte count.
Addresses:
When parsing numpy (.npy) files, the
ParseHeaderContentsfunction reads arbitrary int64_t shape values from the file header. Thevolume()function multiplies all shape dimensions together without overflow checking. The result is used inHeaderData::nbytes()which computestype_info->size() * size()(both size_t). A crafted .npy file with shape dimensions whose product overflows int64_t (e.g., shape=(2^32, 2^32)) would causevolume()to return a small or negative value, leading to an undersized memory allocation inTensor::Resize(), followed by a buffer overflow when reading file data into the undersized buffer.Additional information:
Affected modules and functionalities:
.npyheader parsing andHeaderDatasize calculationKey points relevant for the review:
size_tlimit.Tests:
Checklist
Documentation
DALI team only
Requirements
REQ IDs: N/A
JIRA TASK: N/A