From: Vincent Fu Date: Mon, 30 Jan 2023 15:37:48 +0000 (-0500) Subject: lib/pattern: Fix seg fault when calculating pattern length X-Git-Tag: fio-3.34~45 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=c6cade164bc7e35e95ba88f816be4f44475e4e23 lib/pattern: Fix seg fault when calculating pattern length 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 --- diff --git a/lib/pattern.c b/lib/pattern.c index 9be29af6..e31d4734 100644 --- a/lib/pattern.c +++ b/lib/pattern.c @@ -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);