From 38789b58775ee5e00f4669f01b3c9da31a7345e3 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 3 Mar 2010 09:23:20 +0100 Subject: [PATCH] Add check for OPT_LEN_MAX being too small Will hopefully catch a bug like this in the future. Signed-off-by: Jens Axboe --- parse.c | 7 +++++++ 1 file changed, 7 insertions(+) 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) { -- 2.25.1