util/nvmutil: check fd path in try_fdpath

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2026-03-16 22:02:17 +00:00
parent ab8929808f
commit cf8cb4bdcc
+5
View File
@@ -3231,6 +3231,8 @@ x_try_fdpath(const char *prefix, int fd, mode_t mode)
unsigned long i = 0; unsigned long i = 0;
unsigned long j; unsigned long j;
struct stat st;
while (prefix[i]) { while (prefix[i]) {
if (i >= PATH_LEN - 1) if (i >= PATH_LEN - 1)
return -1; return -1;
@@ -3246,6 +3248,9 @@ x_try_fdpath(const char *prefix, int fd, mode_t mode)
i += j; i += j;
path[i] = '\0'; path[i] = '\0';
if (stat(path, &st) < 0)
return -1;
return chmod(path, mode); return chmod(path, mode);
} }