Skip to content
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

Fix segfault in h5dump caused by corrupted btree node level #5002

Merged
merged 4 commits into from
Oct 29, 2024

Conversation

bmribler
Copy link
Contributor

@bmribler bmribler commented Oct 24, 2024

Re-do of PR #4862

Added another argument, expected node level, to H5B__iterate_helper to pass down to H5B__cache_deserialize for checking the decoded node level. When this expected level is not known, the new macro H5B_UNKNOWN_NODELEVEL (-1) will be used for not checking the level.

Fixes GH-4432

Added another argument, expected node level, to H5B__iterate_helper to pass down
to H5B__cache_deserialize for checking the decoded node level.  When this expected
level is not known, the new macro H5_UNKNOWN_NODELEVEL (-1) will be used for not
checking the level.

Fixes HDFGroupGH-4432
@bmribler bmribler changed the title Re-do of PR #4862 Fix segfault in h5dump caused by corrupted btree node level Oct 24, 2024
src/H5Bpkg.h Outdated
@@ -60,6 +60,7 @@ typedef struct H5B_t {
typedef struct H5B_cache_ud_t {
H5F_t *f; /* File that B-tree node is within */
const struct H5B_class_t *type; /* Type of tree */
unsigned exp_level; /* Expected level of the current node */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd make this an int and not unsigned since -1 is a valid value.

@derobins derobins added Priority - 1. High 🔼 These are important issues that should be resolved in the next release Component - Build CMake, Autotools Type - Improvement Improvements that don't add a new feature or functionality labels Oct 25, 2024
src/H5Bprivate.h Outdated
/* Indicates that the level of the current node is unknown. When the level
* is known, it can be used to detect corrupted level during decoding
*/
#define H5B_UNKNOWN_NODELEVEL (unsigned)-1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably move to H5Bpkg.h

Copy link
Contributor

@qkoziol qkoziol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't help if the level in the root B-tree node is corrupted, but (again) tightens the bounds.

@derobins derobins merged commit 5bdd379 into HDFGroup:develop Oct 29, 2024
61 checks passed
brtnfld pushed a commit to brtnfld/hdf5 that referenced this pull request Oct 31, 2024
…#5002)

Added another argument, expected node level, to H5B__iterate_helper to pass down
to H5B__cache_deserialize for checking the decoded node level.  When this expected
level is not known, the new macro H5_UNKNOWN_NODELEVEL (-1) will be used for not
checking the level.

Fixes HDFGroupGH-4432
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component - Build CMake, Autotools Priority - 1. High 🔼 These are important issues that should be resolved in the next release Type - Improvement Improvements that don't add a new feature or functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

StackOverflow in vasprintf.c
4 participants