From c6cade164bc7e35e95ba88f816be4f44475e4e23 Mon Sep 17 00:00:00 2001 From: Vincent Fu Date: Mon, 30 Jan 2023 10:37:48 -0500 Subject: [PATCH] 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 --- lib/pattern.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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); -- 2.25.1