From: Jens Axboe Date: Wed, 7 Nov 2012 12:47:22 +0000 (+0100) Subject: Add safe checks for valid pareto input value X-Git-Tag: fio-2.0.11~26 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=078189c148e6e0e42894033cf5e19bd6028ca288;ds=sidebyside Add safe checks for valid pareto input value Signed-off-by: Jens Axboe --- diff --git a/options.c b/options.c index ea1ffb13..c240692f 100644 --- 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; } diff --git a/t/genzipf.c b/t/genzipf.c index d06f5619..c3ab4ae1 100644 --- a/t/genzipf.c +++ b/t/genzipf.c @@ -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;