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

Avoid calling H5Ropen_object with a misaligned H5R_ref_t: copy the #1171

Merged
merged 5 commits into from
Nov 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions tools/lib/h5tools.c
Original file line number Diff line number Diff line change
Expand Up @@ -1890,15 +1890,21 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
hid_t region_id = H5I_INVALID_HID;
hid_t region_space = H5I_INVALID_HID;
H5S_sel_type region_type;
H5R_ref_t tref;

if (size > sizeof(tref))
H5TOOLS_THROW((-1), "unexpectedly large ref");

HDmemset(&tref, 0, sizeof(tref));

for (block_index = 0; block_index < block_nelmts; block_index++) {
mem = ((unsigned char *)_mem) + block_index * size;
if ((region_id = H5Ropen_object((H5R_ref_t *)mem, H5P_DEFAULT, H5P_DEFAULT)) < 0)
HDmemcpy(&tref, mem, size);
if ((region_id = H5Ropen_object(&tref, H5P_DEFAULT, H5P_DEFAULT)) < 0)
H5TOOLS_INFO("H5Ropen_object H5T_STD_REF failed");
else {
if ((region_space = H5Ropen_region((H5R_ref_t *)mem, H5P_DEFAULT, H5P_DEFAULT)) >=
0) {
if (!h5tools_is_zero(mem, H5Tget_size(H5T_STD_REF))) {
if ((region_space = H5Ropen_region(&tref, H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
if (!h5tools_is_zero(&tref, H5Tget_size(H5T_STD_REF))) {
region_type = H5Sget_select_type(region_space);
if (region_type == H5S_SEL_POINTS)
render_bin_output_region_points(region_space, region_id, stream,
Expand Down