summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorjhendersonHDF <jhenderson@hdfgroup.org>2021-09-14 20:24:01 (GMT)
committerGitHub <noreply@github.com>2021-09-14 20:24:01 (GMT)
commitcd2ca91875be7d3ee98ab0131c32b9ee072509e5 (patch)
treebc73d8cd6acbe9f2f76dcbcc21374dc0b38e9908 /tools
parent7c973deaf1e602cf165a39860e574a9b5468d164 (diff)
downloadhdf5-cd2ca91875be7d3ee98ab0131c32b9ee072509e5.zip
hdf5-cd2ca91875be7d3ee98ab0131c32b9ee072509e5.tar.gz
hdf5-cd2ca91875be7d3ee98ab0131c32b9ee072509e5.tar.bz2
Fix several warnings (#720)
Diffstat (limited to 'tools')
-rw-r--r--tools/lib/h5tools_str.c3
-rw-r--r--tools/src/h5dump/h5dump_ddl.c20
-rw-r--r--tools/src/h5import/h5import.c7
3 files changed, 21 insertions, 9 deletions
diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c
index 5fcaee6..abc0058 100644
--- a/tools/lib/h5tools_str.c
+++ b/tools/lib/h5tools_str.c
@@ -258,7 +258,8 @@ h5tools_str_fmt(h5tools_str_t *str /*in,out*/, size_t start, const char *fmt)
HDassert(temp);
}
- HDstrncpy(temp, str->s + start, n);
+ HDstrncpy(temp, str->s + start, n - 1);
+ temp[n - 1] = '\0';
}
/* Reset the output string and append a formatted version */
diff --git a/tools/src/h5dump/h5dump_ddl.c b/tools/src/h5dump/h5dump_ddl.c
index 2a69ca6..638a738 100644
--- a/tools/src/h5dump/h5dump_ddl.c
+++ b/tools/src/h5dump/h5dump_ddl.c
@@ -1343,13 +1343,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);
@@ -1421,10 +1429,10 @@ lnk_search(const char *path, const H5L_info2_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) {
diff --git a/tools/src/h5import/h5import.c b/tools/src/h5import/h5import.c
index 04e1c35..6517e43 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);
}