From: Jens Axboe Date: Thu, 6 Dec 2012 16:34:57 +0000 (+0100) Subject: parser: always match the correct option length for posval options X-Git-Tag: fio-2.0.12~24 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=119cd939010b646825d06ac04af41dc5268f2765;ds=sidebyside parser: always match the correct option length for posval options Right now we match rw=randr as rw=randrw, since we use the length of the passed in option. Use a correct max of the ival and string passed in, so that we fail if a full match isn't present. Signed-off-by: Jens Axboe --- diff --git a/parse.c b/parse.c index 13783fa6..18c45301 100644 --- a/parse.c +++ b/parse.c @@ -344,6 +344,11 @@ static int opt_len(const char *str) return (int)(postfix - str); } +static int str_match_len(const struct value_pair *vp, const char *str) +{ + return max(strlen(vp->ival), opt_len(str)); +} + #define val_store(ptr, val, off, or, data) \ do { \ ptr = td_var((data), (off)); \ @@ -388,7 +393,7 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, if (!vp->ival || vp->ival[0] == '\0') continue; all_skipped = 0; - if (!strncmp(vp->ival, ptr, opt_len(ptr))) { + if (!strncmp(vp->ival, ptr, str_match_len(vp, ptr))) { ret = 0; if (o->roff1) { if (vp->or) @@ -549,7 +554,7 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, if (!vp->ival || vp->ival[0] == '\0') continue; all_skipped = 0; - if (!strncmp(vp->ival, ptr, opt_len(ptr))) { + if (!strncmp(vp->ival, ptr, str_match_len(vp, ptr))) { char *rest; ret = 0;