Add safe checks for valid pareto input value
[fio.git] / options.c
index ea1ffb13dd8bf95dd0f8c0bb1bbb0a8f257921c0..c240692f6ccc26d3f415f6bbe3a6640ff32348f2 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;
 }