]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared/vpick: check deterministic suffix earlier 32370/head
authorMike Yuan <me@yhndnzj.com>
Fri, 19 Apr 2024 23:17:04 +0000 (07:17 +0800)
committerMike Yuan <me@yhndnzj.com>
Fri, 19 Apr 2024 23:17:04 +0000 (07:17 +0800)
Follow-up for 421a4ba7e4a26332c271359a7a114a1da7a2afad

src/shared/vpick.c

index fe332189be520eff68a9475e6c99b291c48a6bee..4720e7448d8acfedd4492a8a022c1ecbe801ecfb 100644 (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;