-
-
Notifications
You must be signed in to change notification settings - Fork 276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add buffer overrun checks to H5O__layout_decode and H5O__sdspace_decode #2679
Add buffer overrun checks to H5O__layout_decode and H5O__sdspace_decode #2679
Conversation
70c5d53
to
c17ca84
Compare
/* Check if a read of size bytes starting at ptr would overflow past | ||
* the last valid byte, pointed to by buffer_end. | ||
*/ | ||
#define H5_IS_BUFFER_OVERFLOW(ptr, size, buffer_end) (((ptr) + (size)-1) > (buffer_end)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Borrowing this until we determine final placement..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest H5E_NOSPACE -> H5E_OVERFLOW
"Address overflowed" seems a bit awkward to me as well to describe the issue that occurred, but I don't have any strong opinion either way. I can change it. |
21b9dd7
to
47bb446
Compare
src/H5Olayout.c
Outdated
@@ -164,29 +180,46 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNU | |||
* size in the dataset code, where we've got the dataspace | |||
* information available also. - QAK 5/26/04 | |||
*/ | |||
if (H5_IS_BUFFER_OVERFLOW(p, (ndims * sizeof(uint32_t)), p_end)) | |||
HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") | |||
p += ndims * 4; /* Skip over dimension sizes (32-bit quantities) */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this '4' be replaced with a size call to match the overflow check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Changed.
47bb446
to
df97bbc
Compare
…de (HDFGroup#2679) Co-authored-by: Larry Knox <[email protected]>
…de (HDFGroup#2679) Co-authored-by: Larry Knox <[email protected]>
…de (HDFGroup#2679) Co-authored-by: Larry Knox <[email protected]>
…de (HDFGroup#2679) Co-authored-by: Larry Knox <[email protected]>
…de (HDFGroup#2679) Co-authored-by: Larry Knox <[email protected]>
…de (HDFGroup#2679) Co-authored-by: Larry Knox <[email protected]>
No description provided.