.BR -l | --long | --full
Run a full check, 4GB files with 4k blocks
.TP
+.BR -n | --num_dirs " \fICOUNT"
+\fICOUNT\fR number of sub-directories to create. (\fICOUNT\fR must be >0 and <= INT_MAX)
+.TP
.BR -o | --offset " \fIOFFSET_KB"
offset of IO start in kilobytes (default=0), with optional KMGTP suffix.
.TP
progname = strrchr(argv[0], '/') ? strrchr(argv[0], '/') + 1 : argv[0];
while ((c = getopt_long(argc, argv, "c:hln:o:pqrs:t:vw",
long_opts, NULL)) != -1) {
+ unsigned long val; /* Staging value for num_dirs */
+
switch (c) {
case 'c':
chunksize = strtoul(optarg, NULL, 0) * ONE_MB;
full = 1;
break;
case 'n':
- num_dirs = strtoul(optarg, NULL, 0);
+ /* num_dirs cannot be negative */
+ if (optarg[0] == '-')
+ goto out_num_dirs;
+ val = strtoul(optarg, NULL, 0);
+ if (val == 0 || val > INT_MAX || errno == ERANGE)
+ goto out_num_dirs;
+ num_dirs = val;
break;
+out_num_dirs:
+ fprintf(stderr, "%s: bad directory count '%s'", optarg,
+ progname);
+ usage(1);
+ return -1;
case 'o': /* offset */
dir_num = strtoul(optarg, NULL, 0);
break;