diff options
author | jhendersonHDF <jhenderson@hdfgroup.org> | 2022-04-14 14:05:40 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-14 14:05:40 (GMT) |
commit | 3961f6500d8303ff03bdd8fb38b0edc618b128ab (patch) | |
tree | e5866d374dfb2151e58d1ec1a64e9449fe6be504 /tools/src/h5dump | |
parent | 1a1e59172dc6312808981baeca4bc1772e126ff3 (diff) | |
download | hdf5-3961f6500d8303ff03bdd8fb38b0edc618b128ab.zip hdf5-3961f6500d8303ff03bdd8fb38b0edc618b128ab.tar.gz hdf5-3961f6500d8303ff03bdd8fb38b0edc618b128ab.tar.bz2 |
Hdf5 1 10 merges (#1633)
Diffstat (limited to 'tools/src/h5dump')
-rw-r--r-- | tools/src/h5dump/h5dump_ddl.c | 24 | ||||
-rw-r--r-- | tools/src/h5dump/h5dump_xml.c | 13 |
2 files changed, 25 insertions, 12 deletions
diff --git a/tools/src/h5dump/h5dump_ddl.c b/tools/src/h5dump/h5dump_ddl.c index 3a9a939..e0bd63e 100644 --- a/tools/src/h5dump/h5dump_ddl.c +++ b/tools/src/h5dump/h5dump_ddl.c @@ -1295,7 +1295,7 @@ attr_search(hid_t oid, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *a j = (int)HDstrlen(op_name) - 1; /* find the last / */ while (j >= 0) { - if (op_name[j] == '/' && (j == 0 || (j > 0 && op_name[j - 1] != '\\'))) + if (op_name[j] == '/' && (j == 0 || (op_name[j - 1] != '\\'))) break; j--; } @@ -1320,13 +1320,21 @@ attr_search(hid_t oid, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *a ret = FAIL; } else { + size_t buffer_space = w - 1; + HDmemset(obj_name, '\0', w); if (op_name[0] != '/') { - HDstrncat(obj_name, buf, u + 1); - if (buf[u - 1] != '/') - HDstrncat(obj_name, "/", (size_t)2); + HDstrncat(obj_name, buf, buffer_space); + buffer_space -= MIN(buffer_space, u); + + if (buf[u - 1] != '/') { + HDstrncat(obj_name, "/", buffer_space); + buffer_space -= MIN(buffer_space, 2); + } } - HDstrncat(obj_name, op_name, v + 1); + + HDstrncat(obj_name, op_name, buffer_space); + buffer_space -= MIN(buffer_space, v); handle_attributes(oid, obj_name, NULL, 0, NULL); HDfree(obj_name); @@ -1396,10 +1404,10 @@ lnk_search(const char *path, const H5L_info_t *li, void *_op_data) else { if (k == 2) { HDstrcpy(search_name, "/"); - HDstrncat(search_name, op_name, search_len + 1); + HDstrcat(search_name, op_name); } else - HDstrncpy(search_name, op_name, search_len + 1); + HDstrcpy(search_name, op_name); search_name[search_len + k - 1] = '\0'; if (HDstrcmp(path, search_name) == 0) { @@ -1508,7 +1516,7 @@ handle_attributes(hid_t fid, const char *attr, void H5_ATTR_UNUSED *data, int H5 /* find the last / */ while (j >= 0) { - if (attr[j] == '/' && (j == 0 || (j > 0 && attr[j - 1] != '\\'))) + if (attr[j] == '/' && (j == 0 || (attr[j - 1] != '\\'))) break; j--; } diff --git a/tools/src/h5dump/h5dump_xml.c b/tools/src/h5dump/h5dump_xml.c index 61c2ce2..ec14fdc 100644 --- a/tools/src/h5dump/h5dump_xml.c +++ b/tools/src/h5dump/h5dump_xml.c @@ -588,6 +588,8 @@ xml_name_to_XID(const char *str, char *outstr, int outlen, int gen) if (outlen < 22) return 1; + H5_CHECK_OVERFLOW(outlen, int, size_t); + objno = ref_path_table_lookup(str); if (objno == HADDR_UNDEF) { if (HDstrlen(str) == 0) { @@ -595,7 +597,7 @@ xml_name_to_XID(const char *str, char *outstr, int outlen, int gen) if (objno == HADDR_UNDEF) { if (gen) { objno = ref_path_table_gen_fake(str); - HDsprintf(outstr, "xid_" H5_PRINTF_HADDR_FMT, objno); + HDsnprintf(outstr, (size_t)outlen, "xid_" H5_PRINTF_HADDR_FMT, objno); return 0; } else { @@ -606,7 +608,7 @@ xml_name_to_XID(const char *str, char *outstr, int outlen, int gen) else { if (gen) { objno = ref_path_table_gen_fake(str); - HDsprintf(outstr, "xid_" H5_PRINTF_HADDR_FMT, objno); + HDsnprintf(outstr, (size_t)outlen, "xid_" H5_PRINTF_HADDR_FMT, objno); return 0; } else { @@ -615,7 +617,7 @@ xml_name_to_XID(const char *str, char *outstr, int outlen, int gen) } } - HDsprintf(outstr, "xid_" H5_PRINTF_HADDR_FMT, objno); + HDsnprintf(outstr, (size_t)outlen, "xid_" H5_PRINTF_HADDR_FMT, objno); return 0; } @@ -3557,7 +3559,10 @@ xml_dump_fill_value(hid_t dcpl, hid_t type) h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "\""); for (i = 0; i < sz; i++) { - h5tools_str_append(&buffer, "%x ", *(unsigned int *)buf + (i * sizeof(unsigned int))); + unsigned long val = *(unsigned int *)buf + (i * sizeof(unsigned int)); + + H5_CHECK_OVERFLOW(val, unsigned long, unsigned); + h5tools_str_append(&buffer, "%x ", (unsigned)val); } h5tools_str_append(&buffer, "\""); h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, |