]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
condition: properly handle fnmatch() errors in ConditionHost
authorLennart Poettering <lennart@poettering.net>
Mon, 29 Aug 2022 09:11:10 +0000 (11:11 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 31 Aug 2022 15:31:28 +0000 (17:31 +0200)
src/shared/condition.c

index 27a0a465be697cc10818f42639ca22eda1c49b04..00d732e6ef63ba3c1609d9929fab5de7c360db57 100644 (file)
@@ -716,7 +716,13 @@ static int condition_test_host(Condition *c, char **env) {
         if (!h)
                 return -ENOMEM;
 
-        return fnmatch(c->parameter, h, FNM_CASEFOLD) == 0;
+        r = fnmatch(c->parameter, h, FNM_CASEFOLD);
+        if (r == FNM_NOMATCH)
+                return false;
+        if (r != 0)
+                return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), "fnmatch() failed.");
+
+        return true;
 }
 
 static int condition_test_ac_power(Condition *c, char **env) {