diff options
author | jhendersonHDF <jhenderson@hdfgroup.org> | 2022-02-04 16:53:55 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-04 16:53:55 (GMT) |
commit | 36d9a165e428eb883f9fd72b6707555536292845 (patch) | |
tree | 61848a7a985725dcbb52daab3a986ff490cf909c /tools/src/h5dump | |
parent | 856de93673f2bd097b90e2803475ef4fc3d689fa (diff) | |
download | hdf5-36d9a165e428eb883f9fd72b6707555536292845.zip hdf5-36d9a165e428eb883f9fd72b6707555536292845.tar.gz hdf5-36d9a165e428eb883f9fd72b6707555536292845.tar.bz2 |
Fix a few issues noted by LGTM (#1421)
Diffstat (limited to 'tools/src/h5dump')
-rw-r--r-- | tools/src/h5dump/h5dump_ddl.c | 4 | ||||
-rw-r--r-- | tools/src/h5dump/h5dump_xml.c | 13 |
2 files changed, 11 insertions, 6 deletions
diff --git a/tools/src/h5dump/h5dump_ddl.c b/tools/src/h5dump/h5dump_ddl.c index 37bb82d..b0bce0c 100644 --- a/tools/src/h5dump/h5dump_ddl.c +++ b/tools/src/h5dump/h5dump_ddl.c @@ -1318,7 +1318,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--; } @@ -1541,7 +1541,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 19efd6f..5f64d6c 100644 --- a/tools/src/h5dump/h5dump_xml.c +++ b/tools/src/h5dump/h5dump_xml.c @@ -591,6 +591,8 @@ xml_name_to_XID(hid_t loc_id, const char *str, char *outstr, int outlen, int gen if (outlen < 22) return 1; + H5_CHECK_OVERFLOW(outlen, int, size_t); + lookup_ret = ref_path_table_lookup(str, &obj_token); if (lookup_ret < 0) { if (HDstrlen(str) == 0) { @@ -600,7 +602,7 @@ xml_name_to_XID(hid_t loc_id, const char *str, char *outstr, int outlen, int gen ref_path_table_gen_fake(str, &obj_token); H5Otoken_to_str(loc_id, &obj_token, &obj_tok_str); - HDsnprintf(outstr, outlen, "xid_%s", obj_tok_str); + HDsnprintf(outstr, (size_t)outlen, "xid_%s", obj_tok_str); H5free_memory(obj_tok_str); return 0; @@ -615,7 +617,7 @@ xml_name_to_XID(hid_t loc_id, const char *str, char *outstr, int outlen, int gen ref_path_table_gen_fake(str, &obj_token); H5Otoken_to_str(loc_id, &obj_token, &obj_tok_str); - HDsnprintf(outstr, outlen, "xid_%s", obj_tok_str); + HDsnprintf(outstr, (size_t)outlen, "xid_%s", obj_tok_str); H5free_memory(obj_tok_str); return 0; @@ -627,7 +629,7 @@ xml_name_to_XID(hid_t loc_id, const char *str, char *outstr, int outlen, int gen } H5Otoken_to_str(loc_id, &obj_token, &obj_tok_str); - HDsnprintf(outstr, outlen, "xid_%s", obj_tok_str); + HDsnprintf(outstr, (size_t)outlen, "xid_%s", obj_tok_str); H5free_memory(obj_tok_str); return 0; @@ -3598,7 +3600,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, |