From: Jens Axboe Date: Thu, 22 Jan 2015 21:51:56 +0000 (-0700) Subject: parse: ensure strings are pre-terminated when using strncpy() X-Git-Tag: fio-2.2.6~29 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=209e10374bb57565f0a61286d1ed8effd50fa95c parse: ensure strings are pre-terminated when using strncpy() Signed-off-by: Jens Axboe --- diff --git a/parse.c b/parse.c index e70ed20b..7912212e 100644 --- a/parse.c +++ b/parse.c @@ -506,6 +506,7 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, if (!is_time && o->is_time) is_time = o->is_time; + tmp[sizeof(tmp) - 1] = '\0'; strncpy(tmp, ptr, sizeof(tmp) - 1); p = strchr(tmp, ','); if (p) @@ -705,6 +706,7 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, char tmp[128]; char *p1, *p2; + tmp[sizeof(tmp) - 1] = '\0'; strncpy(tmp, ptr, sizeof(tmp) - 1); /* Handle bsrange with separate read,write values: */