diff options
author | Sean McBride <sean@rogue-research.com> | 2022-01-28 22:43:48 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-28 22:43:48 (GMT) |
commit | 4ac6ccc0213767be935b2686524937ae93c46e3f (patch) | |
tree | 9cd332106bd623c05f8e6837bed0d1ceab5ad7e9 /test/tmisc.c | |
parent | ad71539d30c799c497953c18352df37d83a75310 (diff) | |
download | hdf5-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/tmisc.c')
-rw-r--r-- | test/tmisc.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/test/tmisc.c b/test/tmisc.c index a28e12e..f8bf602 100644 --- a/test/tmisc.c +++ b/test/tmisc.c @@ -1083,7 +1083,7 @@ test_misc6(void) /* Loop through adding attributes to each dataset */ for (u = 0; u < MISC6_NUMATTR; u++) { /* Create name for attribute */ - HDsprintf(attr_name, "Attr#%u", u); + HDsnprintf(attr_name, sizeof(attr_name), "Attr#%u", u); /* Open the file */ loc_id = H5Fopen(MISC6_FILE, H5F_ACC_RDWR, H5P_DEFAULT); @@ -3034,7 +3034,7 @@ test_misc18(void) /* Loop creating attributes on each dataset, flushing them to the file each time */ for (u = 0; u < 10; u++) { /* Set up attribute name */ - HDsprintf(attr_name, "Attr %u", u); + HDsnprintf(attr_name, sizeof(attr_name), "Attr %u", u); /* Create & close attribute on first dataset */ aid = H5Acreate2(did1, attr_name, H5T_STD_U32LE, sid, H5P_DEFAULT, H5P_DEFAULT); @@ -5504,7 +5504,7 @@ test_misc30(void) CHECK(ret, FAIL, "test_misc30_get_info"); } - HDsprintf(gname, "/g0/group%d", i); + HDsnprintf(gname, sizeof(gname), "/g0/group%d", i); gid = H5Gcreate2(fid, gname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(gid, FAIL, "H5Gcreate2"); |