From: Jens Axboe Date: Wed, 31 Aug 2011 20:29:22 +0000 (-0600) Subject: Fix parser using uninitialized memory X-Git-Tag: fio-1.58~13 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=ce952ab65a46f728ffada9613bb50ace7aeaa7c8 Fix parser using uninitialized memory Introduced by e2979754b554d6a48cffa98f41fb59bc045922ac. Signed-off-by: Jens Axboe --- diff --git a/parse.c b/parse.c index 425411e9..25de29e2 100644 --- a/parse.c +++ b/parse.c @@ -26,14 +26,11 @@ static int vp_cmp(const void *p1, const void *p2) return strlen(vp2->ival) - strlen(vp1->ival); } -static int posval_sort(struct fio_option *o, struct value_pair *vpmap) +static void posval_sort(struct fio_option *o, struct value_pair *vpmap) { const struct value_pair *vp; int entries; - if (!o->posval[0].ival) - return 0; - memset(vpmap, 0, PARSE_MAX_VP * sizeof(struct value_pair)); for (entries = 0; entries < PARSE_MAX_VP; entries++) { @@ -45,7 +42,6 @@ static int posval_sort(struct fio_option *o, struct value_pair *vpmap) } qsort(vpmap, entries, sizeof(struct value_pair), vp_cmp); - return 1; } static void show_option_range(struct fio_option *o, FILE *out) @@ -491,7 +487,9 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, case FIO_OPT_STR_STORE: { fio_opt_str_fn *fn = o->cb; - if (!posval_sort(o, posval)) + posval_sort(o, posval); + + if (!o->posval[0].ival) goto match; ret = 1;