From 020b66d8507340d49172fee3bf221ec676a8f18b Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 21 Dec 2022 17:12:13 +0100 Subject: [PATCH] =?UTF-8?q?analyze:=20basename()=20=E2=86=92=20path=5Fextr?= =?UTF-8?q?act=5Ffilename()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/analyze/analyze-verify-util.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/analyze/analyze-verify-util.c b/src/analyze/analyze-verify-util.c index a646e5807c..b9f08b6d85 100644 --- a/src/analyze/analyze-verify-util.c +++ b/src/analyze/analyze-verify-util.c @@ -36,12 +36,9 @@ static void log_syntax_callback(const char *unit, int level, void *userdata) { } int verify_prepare_filename(const char *filename, char **ret) { - int r; - const char *name; - _cleanup_free_ char *abspath = NULL; - _cleanup_free_ char *dir = NULL; - _cleanup_free_ char *with_instance = NULL; + _cleanup_free_ char *abspath = NULL, *name = NULL, *dir = NULL, *with_instance = NULL; char *c; + int r; assert(filename); assert(ret); @@ -50,7 +47,10 @@ int verify_prepare_filename(const char *filename, char **ret) { if (r < 0) return r; - name = basename(abspath); + r = path_extract_filename(abspath, &name); + if (r < 0) + return r; + if (!unit_name_is_valid(name, UNIT_NAME_ANY)) return -EINVAL;