X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=parse.c;h=745056bdc8186e54743d2fb688df926084c91853;hb=refs%2Ftags%2Ffio-2.2.9;hp=e70ed20bda7e64b3727e93cacad71de65148862b;hpb=1d31d1bcffe0b282aaadca12dc83d2dd671b84f2;p=fio.git diff --git a/parse.c b/parse.c index e70ed20b..745056bd 100644 --- a/parse.c +++ b/parse.c @@ -17,6 +17,7 @@ #include "options.h" #include "minmax.h" #include "lib/ieee754.h" +#include "lib/pow2.h" #ifdef CONFIG_ARITHMETIC #include "y.tab.h" @@ -506,6 +507,7 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, if (!is_time && o->is_time) is_time = o->is_time; + tmp[sizeof(tmp) - 1] = '\0'; strncpy(tmp, ptr, sizeof(tmp) - 1); p = strchr(tmp, ','); if (p) @@ -520,6 +522,10 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, if (ret) break; + if (o->pow2 && !is_power_of_2(ull)) { + log_err("%s: must be a power-of-2\n", o->name); + return 1; + } if (o->maxval && ull > o->maxval) { log_err("max value out of range: %llu" @@ -705,6 +711,7 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, char tmp[128]; char *p1, *p2; + tmp[sizeof(tmp) - 1] = '\0'; strncpy(tmp, ptr, sizeof(tmp) - 1); /* Handle bsrange with separate read,write values: */