diff options
author | Sean McBride <sean@rogue-research.com> | 2022-06-22 18:58:18 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-22 18:58:18 (GMT) |
commit | c064d3481b582653c1e0d0043a17527fd73e8c4d (patch) | |
tree | 396a5e13954c19b803aa80465938cde15140b176 /test/swmr_common.c | |
parent | d6f05069c1a3642bbebf7ec27e7df809f0675f13 (diff) | |
download | hdf5-c064d3481b582653c1e0d0043a17527fd73e8c4d.zip hdf5-c064d3481b582653c1e0d0043a17527fd73e8c4d.tar.gz hdf5-c064d3481b582653c1e0d0043a17527fd73e8c4d.tar.bz2 |
sprintf to snprintf (#1815)
* Straightforward conversion of sprintf to the safer snprintf
* Trickier conversion of sprintf to safer snprintf
This involved minor changes to private function signatures to take the size of the buffer.
* Committing clang-format changes
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'test/swmr_common.c')
-rw-r--r-- | test/swmr_common.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/test/swmr_common.c b/test/swmr_common.c index b359bc6..9063ddd 100644 --- a/test/swmr_common.c +++ b/test/swmr_common.c @@ -162,6 +162,9 @@ create_symbol_datatype(void) * Buffer for the created name. Must be pre-allocated. * Since the name is formulaic, this isn't considered an issue. * + * size_t name_buf_length + * The length in bytes of the name_buf buffer + * * unsigned level * The dataset's level * @@ -175,11 +178,11 @@ create_symbol_datatype(void) *------------------------------------------------------------------------- */ int -generate_name(char *name_buf, unsigned level, unsigned count) +generate_name(char *name_buf, size_t name_buf_length, unsigned level, unsigned count) { HDassert(name_buf); - HDsprintf(name_buf, "%u-%04u", level, count); + HDsnprintf(name_buf, name_buf_length, "%u-%04u", level, count); return 0; } /* end generate_name() */ @@ -206,7 +209,7 @@ generate_symbols(void) for (v = 0; v < symbol_count[u]; v++) { char name_buf[64]; - generate_name(name_buf, u, v); + generate_name(name_buf, sizeof(name_buf), u, v); symbol_info[u][v].name = HDstrdup(name_buf); symbol_info[u][v].dsid = -1; symbol_info[u][v].nrecords = 0; |