Merge branch 'fix_keyword_sub' of https://github.com/sitsofe/fio
authorJens Axboe <axboe@kernel.dk>
Sat, 16 Jan 2021 03:52:57 +0000 (20:52 -0700)
committerJens Axboe <axboe@kernel.dk>
Sat, 16 Jan 2021 03:52:57 +0000 (20:52 -0700)
* 'fix_keyword_sub' of https://github.com/sitsofe/fio:
  options: fix keyword substitution heap overrun

options.c

index 47b20c247987d8b44147fc57e91fc90c8f1ac569..0b4c48d618150562c78c1af364f72121bbb15b7a 100644 (file)
--- a/options.c
+++ b/options.c
@@ -5115,10 +5115,10 @@ static char *fio_keyword_replace(char *opt)
                         * If there's more in the original string, copy that
                         * in too
                         */
-                       opt += strlen(kw->word) + olen;
+                       opt += olen + strlen(kw->word);
                        /* keeps final zero thanks to calloc */
                        if (strlen(opt))
-                               memcpy(new + olen + len, opt, opt - o_org - 1);
+                               memcpy(new + olen + len, opt, strlen(opt));
 
                        /*
                         * replace opt and free the old opt