lib/pattern: Fix seg fault when calculating pattern length
authorVincent Fu <vincent.fu@samsung.com>
Mon, 30 Jan 2023 15:37:48 +0000 (10:37 -0500)
committerVincent Fu <vincent.fu@samsung.com>
Mon, 30 Jan 2023 15:46:22 +0000 (10:46 -0500)
When --buffer_pattern or --verify_pattern has multiple elements
(0x110x22 or 0xdeadface"abcd"-12'filename') calculating the length
produces a segmentation fault in parse_and_fill_pattern() because it
increments out when out is passed to the parse_* routines it calls.

This patch uses the fix provided in the GitHub issue.

Fixes: https://github.com/axboe/fio/issues/1500
Fixes: 6c9397396eb83a6ce64a998795e7a50552e4337e "lib/pattern: Support
NULL output buffer in parse_and_fill_pattern()"

Signed-off-by: Vincent Fu <vincent.fu@samsung.com>
lib/pattern.c

index 9be29af6bcf591adea3323dafee9b48684002c44..e31d4734713a5a9cd1fb8a46fa1dffdb0411e718 100644 (file)
@@ -386,7 +386,8 @@ static int parse_and_fill_pattern(const char *in, unsigned int in_len,
                assert(filled);
                assert(filled <= out_len);
                out_len -= filled;
-               out     += filled;
+               if (out)
+                       out     += filled;
                total   += filled;
 
        } while (in_len);