From: Jens Axboe Date: Wed, 3 Mar 2010 08:23:20 +0000 (+0100) Subject: Add check for OPT_LEN_MAX being too small X-Git-Tag: fio-1.38~43 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=38789b58775ee5e00f4669f01b3c9da31a7345e3;p=fio.git Add check for OPT_LEN_MAX being too small Will hopefully catch a bug like this in the future. Signed-off-by: Jens Axboe --- diff --git a/parse.c b/parse.c index a55e52b0..d44d1308 100644 --- a/parse.c +++ b/parse.c @@ -620,6 +620,11 @@ static char *option_dup_subs(const char *opt) ssize_t nchr = OPT_LEN_MAX; size_t envlen; + if (strlen(in) + 1 > OPT_LEN_MAX) { + fprintf(stderr, "OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX); + return NULL; + } + in[OPT_LEN_MAX] = '\0'; strncpy(in, opt, OPT_LEN_MAX); @@ -659,6 +664,8 @@ int parse_option(const char *opt, struct fio_option *options, void *data) char *post, *tmp; tmp = option_dup_subs(opt); + if (!tmp) + return 1; o = get_option(tmp, options, &post); if (!o) {