From b6d31deca4acc7fd6b6e65e51386002014d4a365 Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Sat, 20 Apr 2024 07:17:04 +0800 Subject: [PATCH] shared/vpick: check deterministic suffix earlier Follow-up for 421a4ba7e4a26332c271359a7a114a1da7a2afad --- src/shared/vpick.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/shared/vpick.c b/src/shared/vpick.c index fe332189be5..4720e7448d8 100644 --- a/src/shared/vpick.c +++ b/src/shared/vpick.c @@ -34,6 +34,8 @@ static int format_fname( if (FLAGS_SET(flags, PICK_TRIES) || !filter->version) /* Underspecified? */ return -ENOEXEC; + if (strv_length(filter->suffix) > 1) /* suffix is not deterministic? */ + return -ENOEXEC; /* The format for names we match goes like this: * @@ -85,13 +87,9 @@ static int format_fname( return -ENOMEM; } - if (!strv_isempty(filter->suffix)) { - if (strv_length(filter->suffix) > 1) - return -ENOEXEC; - + if (!strv_isempty(filter->suffix)) if (!strextend(&fn, filter->suffix[0])) return -ENOMEM; - } if (!filename_is_valid(fn)) return -EINVAL; -- 2.47.3