summaryrefslogtreecommitdiffstats
path: root/tools/src
diff options
context:
space:
mode:
authorjhendersonHDF <jhenderson@hdfgroup.org>2022-04-14 14:05:40 (GMT)
committerGitHub <noreply@github.com>2022-04-14 14:05:40 (GMT)
commit3961f6500d8303ff03bdd8fb38b0edc618b128ab (patch)
treee5866d374dfb2151e58d1ec1a64e9449fe6be504 /tools/src
parent1a1e59172dc6312808981baeca4bc1772e126ff3 (diff)
downloadhdf5-3961f6500d8303ff03bdd8fb38b0edc618b128ab.zip
hdf5-3961f6500d8303ff03bdd8fb38b0edc618b128ab.tar.gz
hdf5-3961f6500d8303ff03bdd8fb38b0edc618b128ab.tar.bz2
Hdf5 1 10 merges (#1633)
Diffstat (limited to 'tools/src')
-rw-r--r--tools/src/h5dump/h5dump_ddl.c24
-rw-r--r--tools/src/h5dump/h5dump_xml.c13
-rw-r--r--tools/src/h5import/h5import.c7
-rw-r--r--tools/src/h5perf/sio_perf.c2
4 files changed, 31 insertions, 15 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,
diff --git a/tools/src/h5import/h5import.c b/tools/src/h5import/h5import.c
index 100eba3..509cc87 100644
--- a/tools/src/h5import/h5import.c
+++ b/tools/src/h5import/h5import.c
@@ -3771,6 +3771,7 @@ getCompressionParameter(struct Input *in, FILE *strm)
static int
getExternalFilename(struct Input *in, FILE *strm)
{
+ size_t temp_len;
char temp[255];
const char *err1 = "Unable to get 'string' value.\n";
@@ -3779,8 +3780,10 @@ getExternalFilename(struct Input *in, FILE *strm)
return (-1);
}
- in->externFilename = (char *)HDmalloc((size_t)(HDstrlen(temp) + 1) * sizeof(char));
- (void)HDstrncpy(in->externFilename, temp, HDstrlen(temp) + 1);
+ temp_len = HDstrlen(temp);
+ in->externFilename = (char *)HDmalloc((temp_len + 1) * sizeof(char));
+ (void)HDstrcpy(in->externFilename, temp);
+ in->externFilename[temp_len] = '\0';
return (0);
}
diff --git a/tools/src/h5perf/sio_perf.c b/tools/src/h5perf/sio_perf.c
index c979e7a..b2dd765 100644
--- a/tools/src/h5perf/sio_perf.c
+++ b/tools/src/h5perf/sio_perf.c
@@ -277,7 +277,7 @@ run_test_loop(struct options *opts)
}
/* print size information */
- output_report("Transfer Buffer Size (bytes): %d\n", buf_bytes);
+ output_report("Transfer Buffer Size (bytes): %zu\n", buf_bytes);
output_report("File Size(MB): %.2f\n", ((double)parms.num_bytes) / ONE_MB);
print_indent(0);