Add safe checks for valid pareto input value
authorJens Axboe <axboe@kernel.dk>
Wed, 7 Nov 2012 12:47:22 +0000 (13:47 +0100)
committerJens Axboe <axboe@kernel.dk>
Wed, 7 Nov 2012 12:47:22 +0000 (13:47 +0100)
Signed-off-by: Jens Axboe <axboe@kernel.dk>
options.c
t/genzipf.c

index ea1ffb1..c240692 100644 (file)
--- a/options.c
+++ b/options.c
@@ -748,12 +748,18 @@ static int str_random_distribution_cb(void *data, const char *str)
                return 1;
        }
 
+       free(nr);
+
        if (td->o.random_distribution == FIO_RAND_DIST_ZIPF)
                td->o.zipf_theta = val;
-       else
+       else {
+               if (val <= 0.00 || val >= 1.00) {
+                       log_err("fio: pareto input out of range (0 < input < 1.0)\n");
+                       return 1;
+               }
                td->o.pareto_h = val;
+       }
 
-       free(nr);
        return 0;
 }
 
index d06f561..c3ab4ae 100644 (file)
@@ -137,6 +137,10 @@ int main(int argc, char *argv[])
        }
 
        val = atof(argv[2]);
+       if ((val >= 1.00 || val < 0.00) && !use_zipf) {
+               printf("pareto input must be > 0.00 and < 1.00\n");
+               return 1;
+       }
 
        nranges = DEF_NR;
        output_nranges = DEF_NR_OUTPUT;