From 7f4d5ce9b4ec4e44fbd2e6e6b8dd2e600ddbd72d Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 13 Jan 2026 13:52:41 +0100 Subject: [PATCH] lib/path: Ensure consistent and robust path checks Signed-off-by: Karel Zak --- lib/path.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/path.c b/lib/path.c index 7edc2079b..674f74fd2 100644 --- a/lib/path.c +++ b/lib/path.c @@ -313,7 +313,7 @@ int ul_path_access(struct path_cxt *pc, int mode, const char *path) int dir = ul_path_get_dirfd(pc); if (dir < 0) return dir; - if (*path == '/') + if (path && *path == '/') path++; rc = faccessat(dir, path, mode, 0); @@ -400,10 +400,8 @@ int ul_path_statx(struct path_cxt *pc, struct statx *stx, int flags, unsigned in int dir = ul_path_get_dirfd(pc); if (dir < 0) return dir; - if (path) { - if (*path == '/') - path++; - } + if (path && *path == '/') + path++; rc = statx(dir, path, flags, mask, stx); } -- 2.47.3