From: Jens Axboe Date: Thu, 29 Mar 2007 09:00:43 +0000 (+0200) Subject: Fix memory overflow with > 64 byte options X-Git-Tag: fio-1.15.1~12 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=0401bca6b35ee32681462713ce9bc0cc2accbbf2;p=fio.git Fix memory overflow with > 64 byte options Signed-off-by: Jens Axboe --- diff --git a/parse.c b/parse.c index bf1dea90..ace34a69 100644 --- a/parse.c +++ b/parse.c @@ -452,9 +452,9 @@ int parse_option(const char *opt, struct fio_option *options, void *data) { struct fio_option *o; char *pre, *post; - char tmp[64]; + char *tmp; - strncpy(tmp, opt, sizeof(tmp) - 1); + tmp = strdup(opt); pre = strchr(tmp, '='); if (pre) { @@ -470,13 +470,17 @@ int parse_option(const char *opt, struct fio_option *options, void *data) if (!o) { fprintf(stderr, "Bad option %s\n", tmp); + free(tmp); return 1; } - if (!handle_option(o, post, data)) + if (!handle_option(o, post, data)) { + free(tmp); return 0; + } fprintf(stderr, "fio: failed parsing %s\n", opt); + free(tmp); return 1; }