From: Karel Zak Date: Tue, 13 Jan 2026 12:52:41 +0000 (+0100) Subject: lib/path: Ensure consistent and robust path checks X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7f4d5ce9b4ec4e44fbd2e6e6b8dd2e600ddbd72d;p=thirdparty%2Futil-linux.git lib/path: Ensure consistent and robust path checks Signed-off-by: Karel Zak --- 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); }