parse: ensure strings are pre-terminated when using strncpy()
[fio.git] / parse.c
diff --git a/parse.c b/parse.c
index e70ed20bda7e64b3727e93cacad71de65148862b..7912212ecda47594bac999e8abbecdacaf81aeb1 100644 (file)
--- 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: */