aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2023-09-02 07:35:49 -0600
committerJens Axboe <axboe@kernel.dk>2023-09-02 07:35:49 -0600
commit904ee91c2831615a054a8dea9b164e96ae00abb3 (patch)
tree4db30b95277fb5738e65a8978e26c8745cb6c58a
parent4a0c766c69ddfe5231d65f2676e97333ba89ab2b (diff)
parent2e0a52594ed11e738d2402a3e22d05ec5597535a (diff)
downloadfio-904ee91c2831615a054a8dea9b164e96ae00abb3.tar.gz
Merge branch 'pcpp_parse_nr_fix' of https://github.com/PCPartPicker/fio
* 'pcpp_parse_nr_fix' of https://github.com/PCPartPicker/fio: Add basic error checking to parsing nr from rw=randrw:<nr>, etc
-rw-r--r--options.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/options.c b/options.c
index 48aa0d7b1..65b2813c2 100644
--- a/options.c
+++ b/options.c
@@ -596,9 +596,21 @@ static int str_rw_cb(void *data, const char *str)
if (!nr)
return 0;
- if (td_random(td))
- o->ddir_seq_nr = atoi(nr);
- else {
+ if (td_random(td)) {
+ long long val;
+
+ if (str_to_decimal(nr, &val, 1, o, 0, 0)) {
+ log_err("fio: randrw postfix parsing failed\n");
+ free(nr);
+ return 1;
+ }
+ if ((val <= 0) || (val > UINT_MAX)) {
+ log_err("fio: randrw postfix parsing out of range\n");
+ free(nr);
+ return 1;
+ }
+ o->ddir_seq_nr = (unsigned int) val;
+ } else {
long long val;
if (str_to_decimal(nr, &val, 1, o, 0, 0)) {