From 4f581950c28eeeac38c387e891f36a5bcf2f438f Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Mon, 16 Mar 2026 22:02:17 +0000 Subject: util/nvmutil: check fd path in try_fdpath Signed-off-by: Leah Rowe --- util/nvmutil/nvmutil.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'util/nvmutil') diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index b40a0910..c7093501 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -3231,6 +3231,8 @@ x_try_fdpath(const char *prefix, int fd, mode_t mode) unsigned long i = 0; unsigned long j; + struct stat st; + while (prefix[i]) { if (i >= PATH_LEN - 1) return -1; @@ -3246,6 +3248,9 @@ x_try_fdpath(const char *prefix, int fd, mode_t mode) i += j; path[i] = '\0'; + if (stat(path, &st) < 0) + return -1; + return chmod(path, mode); } -- cgit v1.2.1