From 7d240881676e22629956d83e299787c697b501ad Mon Sep 17 00:00:00 2001 From: Leonid Kozlov Date: Wed, 18 Jun 2025 10:54:46 +0300 Subject: [PATCH] parse: use minimum delimiter distance Use minimal distance to delimiter to determine option length Current implementation of opt_len() makes impossible to locate option name in random_distribution zones list combining ':' and ',' chars. opt_len() function should try to locate option name by all possible delimiters and return minimal length one instead of returning first found. Fixes: https://github.com/axboe/fio/issues/1923 Signed-off-by: Leonid Kozlov --- parse.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/parse.c b/parse.c index 656a5025..5bb55bff 100644 --- a/parse.c +++ b/parse.c @@ -480,14 +480,17 @@ static size_t opt_len(const char *str) char delimiter[] = {',', ':'}; char *postfix; unsigned int i; + size_t candidate_len; + size_t prefix_len = strlen(str); for (i = 0; i < FIO_ARRAY_SIZE(delimiter); i++) { postfix = strchr(str, delimiter[i]); - if (postfix) - return (int)(postfix - str); + candidate_len = (size_t)(postfix - str); + if (postfix && candidate_len < prefix_len) + prefix_len = candidate_len; } - return strlen(str); + return prefix_len; } static int str_match_len(const struct value_pair *vp, const char *str) -- 2.25.1