summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@koziol.gov>2020-04-26 03:52:52 (GMT)
committerQuincey Koziol <koziol@koziol.gov>2020-04-26 03:52:52 (GMT)
commit3f3363177d5cc1efc8fcfc70e1feed7a293da2d4 (patch)
tree2fa76fb21528239e0ac5a4147e467afea29d1ffc
parentc18ed719ecf6eda956189e642aab80b0ff8a3a4e (diff)
downloadhdf5-3f3363177d5cc1efc8fcfc70e1feed7a293da2d4.zip
hdf5-3f3363177d5cc1efc8fcfc70e1feed7a293da2d4.tar.gz
hdf5-3f3363177d5cc1efc8fcfc70e1feed7a293da2d4.tar.bz2
Range check # of 'extra' command-line parameters against array size.
-rw-r--r--tools/src/misc/h5debug.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/tools/src/misc/h5debug.c b/tools/src/misc/h5debug.c
index 1b8d460..e9a783b 100644
--- a/tools/src/misc/h5debug.c
+++ b/tools/src/misc/h5debug.c
@@ -335,7 +335,15 @@ main(int argc, char *argv[])
/* Extra arguments for primary data structure */
HDmemset(extra, 0, sizeof(extra));
if(argc > 3) {
- extra_count = argc - 3; /* Number of extra arguments */
+ /* Number of extra arguments */
+ extra_count = argc - 3;
+
+ /* Range check against 'extra' array size */
+ if(extra_count > (int)(sizeof(extra) / sizeof(haddr_t))) {
+ HDfprintf(stderr, "\nWARNING: Only using first %d extra parameters\n\n", (int)(sizeof(extra) / sizeof(haddr_t)));
+ extra_count = (int)(sizeof(extra) / sizeof(haddr_t));
+ } /* end if */
+
for(u = 0; u < (size_t)extra_count; u++)
extra[u] = (haddr_t)HDstrtoll(argv[u + 3], NULL, 0);
} /* end if */