From 6eeadaa141733cfa5294b0f3ad1420c845c32663 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 29 Aug 2022 11:07:11 +0200 Subject: [PATCH] path-util: return error if fnmatch() fails --- src/basic/path-util.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/basic/path-util.c b/src/basic/path-util.c index c5f30b5be4..338377d918 100644 --- a/src/basic/path-util.c +++ b/src/basic/path-util.c @@ -1336,8 +1336,11 @@ int path_glob_can_match(const char *pattern, const char *prefix, char **ret) { if (!h) return -ENOMEM; - if (fnmatch(g, h, 0) != 0) + r = fnmatch(g, h, 0); + if (r == FNM_NOMATCH) break; + if (r != 0) /* Failure to process pattern? */ + return -EINVAL; } /* The pattern does not match the prefix. */