summaryrefslogtreecommitdiffstats
path: root/test/trefstr.c
diff options
context:
space:
mode:
authorSean McBride <sean@rogue-research.com>2022-01-28 22:43:48 (GMT)
committerGitHub <noreply@github.com>2022-01-28 22:43:48 (GMT)
commit4ac6ccc0213767be935b2686524937ae93c46e3f (patch)
tree9cd332106bd623c05f8e6837bed0d1ceab5ad7e9 /test/trefstr.c
parentad71539d30c799c497953c18352df37d83a75310 (diff)
downloadhdf5-4ac6ccc0213767be935b2686524937ae93c46e3f.zip
hdf5-4ac6ccc0213767be935b2686524937ae93c46e3f.tar.gz
hdf5-4ac6ccc0213767be935b2686524937ae93c46e3f.tar.bz2
Snprintf2 (#1399)
* Replaced many uses of sprintf with safer snprintf Many very straightforward, but in a few cases added a length parameter to some private functions, because buffer length was otherwise unknowable. * Removed unnecessary use of static on small buffers This improves thread safety. * Committing clang-format changes Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'test/trefstr.c')
-rw-r--r--test/trefstr.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/test/trefstr.c b/test/trefstr.c
index d0575ab..89e62db 100644
--- a/test/trefstr.c
+++ b/test/trefstr.c
@@ -309,7 +309,7 @@ test_refstr_asprintf_cat(void)
/* Get pointer to raw string in ref-counted string */
s = H5RS_get_str(rs);
CHECK_PTR(s, "H5RS_get_str");
- HDsprintf(buf, "%d-%s", (int)10, "foo");
+ HDsnprintf(buf, sizeof(buf), "%d-%s", (int)10, "foo");
cmp = HDstrcmp(s, buf);
VERIFY(cmp, 0, "HDstrcmp");
@@ -320,7 +320,7 @@ test_refstr_asprintf_cat(void)
/* Get pointer to raw string in ref-counted string */
s = H5RS_get_str(rs);
CHECK_PTR(s, "H5RS_get_str");
- HDsprintf(buf, "%d-%s-%f", (int)10, "foo", (double)20.0);
+ HDsnprintf(buf, sizeof(buf), "%d-%s-%f", (int)10, "foo", (double)20.0);
cmp = HDstrcmp(s, buf);
VERIFY(cmp, 0, "HDstrcmp");
@@ -360,7 +360,7 @@ test_refstr_acat(void)
/* Get pointer to raw string in ref-counted string */
s = H5RS_get_str(rs);
CHECK_PTR(s, "H5RS_get_str");
- HDsprintf(buf, "%s", "foo");
+ HDsnprintf(buf, sizeof(buf), "%s", "foo");
cmp = HDstrcmp(s, buf);
VERIFY(cmp, 0, "HDstrcmp");
@@ -371,7 +371,7 @@ test_refstr_acat(void)
/* Get pointer to raw string in ref-counted string */
s = H5RS_get_str(rs);
CHECK_PTR(s, "H5RS_get_str");
- HDsprintf(buf, "%s", "foobar");
+ HDsnprintf(buf, sizeof(buf), "%s", "foobar");
cmp = HDstrcmp(s, buf);
VERIFY(cmp, 0, "HDstrcmp");
@@ -386,7 +386,7 @@ test_refstr_acat(void)
/* Get pointer to raw string in ref-counted string */
s = H5RS_get_str(rs);
CHECK_PTR(s, "H5RS_get_str");
- HDsprintf(buf, "%s", "foobar");
+ HDsnprintf(buf, sizeof(buf), "%s", "foobar");
large_str2 = HDmalloc(1024 + 6);
CHECK_PTR(large_str2, "HDmalloc");
HDstrcpy(large_str2, "foobar");