From: Lennart Poettering Date: Mon, 29 Aug 2022 09:11:10 +0000 (+0200) Subject: condition: properly handle fnmatch() errors in ConditionHost X-Git-Tag: v252-rc1~290 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7fd0fb02a1303579f15ccfa987d64a04b2f18d72;p=thirdparty%2Fsystemd.git condition: properly handle fnmatch() errors in ConditionHost --- diff --git a/src/shared/condition.c b/src/shared/condition.c index 27a0a465be6..00d732e6ef6 100644 --- a/src/shared/condition.c +++ b/src/shared/condition.c @@ -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) {