From 078189c148e6e0e42894033cf5e19bd6028ca288 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 7 Nov 2012 13:47:22 +0100 Subject: [PATCH] Add safe checks for valid pareto input value Signed-off-by: Jens Axboe --- options.c | 10 ++++++++-- t/genzipf.c | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) 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; -- 2.25.1