From 7fd0fb02a1303579f15ccfa987d64a04b2f18d72 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 29 Aug 2022 11:11:10 +0200 Subject: [PATCH] condition: properly handle fnmatch() errors in ConditionHost --- src/shared/condition.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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) { -- 2.47.3