Merge branch 'fix_filename_overrun' of https://github.com/sitsofe/fio
authorJens Axboe <axboe@kernel.dk>
Sat, 16 Jan 2021 20:36:27 +0000 (13:36 -0700)
committerJens Axboe <axboe@kernel.dk>
Sat, 16 Jan 2021 20:36:27 +0000 (13:36 -0700)
* 'fix_filename_overrun' of https://github.com/sitsofe/fio:
  options: fix buffer overrun

options.c
parse.c

index 0b4c48d618150562c78c1af364f72121bbb15b7a..955bf959e49c3ff2a8c1c9912786f45b833b346c 100644 (file)
--- a/options.c
+++ b/options.c
@@ -1672,6 +1672,7 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                .lname  = "Filename(s)",
                .type   = FIO_OPT_STR_STORE,
                .off1   = offsetof(struct thread_options, filename),
+               .maxlen = PATH_MAX,
                .cb     = str_filename_cb,
                .prio   = -1, /* must come after "directory" */
                .help   = "File(s) to use for the workload",
diff --git a/parse.c b/parse.c
index c28d82efb0932a5cb37c8b2b9f715c09b78fbfb3..44bf950768d9b51bcc3e43ba30c2564614a6e4c6 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -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)