options: fix buffer overrun
[fio.git] / parse.c
diff --git a/parse.c b/parse.c
index f4cefcf6243edbd911cb4f274611912c440a5f07..44bf950768d9b51bcc3e43ba30c2564614a6e4c6 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -501,7 +501,7 @@ static int str_match_len(const struct value_pair *vp, const char *str)
 
 static const char *opt_type_name(const struct fio_option *o)
 {
-       compiletime_assert(ARRAY_SIZE(opt_type_names) - 1 == FIO_OPT_UNSUPPORTED,
+       compiletime_assert(FIO_ARRAY_SIZE(opt_type_names) - 1 == FIO_OPT_UNSUPPORTED,
                                "opt_type_names[] index");
 
        if (o->type <= FIO_OPT_UNSUPPORTED)
@@ -786,6 +786,11 @@ static int __handle_option(const struct fio_option *o, const char *ptr,
                if (o->off1) {
                        cp = td_var(data, o, o->off1);
                        *cp = strdup(ptr);
+                       if (strlen(ptr) > o->maxlen - 1) {
+                               log_err("value exceeds max length of %d\n",
+                                       o->maxlen);
+                               return 1;
+                       }
                }
 
                if (fn)