shared/vpick: check deterministic suffix earlier

Follow-up for 421a4ba7e4
This commit is contained in:
Mike Yuan
2024-04-20 07:17:04 +08:00
parent fde8fb7466
commit b6d31deca4
+3 -5
View File
@@ -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;