[PATCH] Fix random_map
[fio.git] / parse.c
diff --git a/parse.c b/parse.c
index 7af6be1a93ed2b2f64b50fd406b56e602bdd22ee..9f2ee0d653c7fcdc781caa4eea1a46eee4776074 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -178,7 +178,7 @@ static int handle_option(struct fio_option *o, const char *ptr, void *data)
                char tmp[128];
                char *p1, *p2;
 
-               strcpy(tmp, ptr);
+               strncpy(tmp, ptr, sizeof(tmp) - 1);
 
                p1 = strchr(tmp, '-');
                if (!p1) {
@@ -240,9 +240,6 @@ static int handle_option(struct fio_option *o, const char *ptr, void *data)
                ret = 1;
        }
 
-       if (ret)
-               fprintf(stderr, "fio: failed parsing %s=%s\n", o->name, ptr);
-
        return ret;
 }
 
@@ -257,7 +254,11 @@ int parse_cmd_option(const char *opt, const char *val,
                return 1;
        }
 
-       return handle_option(o, val, data);
+       if (!handle_option(o, val, data))
+               return 0;
+
+       fprintf(stderr, "fio: failed parsing %s=%s\n", opt, val);
+       return 1;
 }
 
 int parse_option(const char *opt, struct fio_option *options, void *data)
@@ -266,7 +267,7 @@ int parse_option(const char *opt, struct fio_option *options, void *data)
        char *pre, *post;
        char tmp[64];
 
-       strcpy(tmp, opt);
+       strncpy(tmp, opt, sizeof(tmp) - 1);
 
        pre = strchr(tmp, '=');
        if (pre) {
@@ -285,5 +286,9 @@ int parse_option(const char *opt, struct fio_option *options, void *data)
                return 1;
        }
 
-       return handle_option(o, post, data);
+       if (!handle_option(o, post, data))
+               return 0;
+
+       fprintf(stderr, "fio: failed parsing %s\n", opt);
+       return 1;
 }