util/nvmutil: add bound check to x_try_fdpath

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2026-03-16 21:53:30 +00:00
parent 841fe878f3
commit 045d85dcc5

View File

@@ -3232,13 +3232,18 @@ x_try_fdpath(const char *prefix, int fd, mode_t mode)
unsigned long j;
while (prefix[i]) {
if (i >= PATH_LEN - 1)
return -1;
path[i] = prefix[i];
i++;
}
j = x_conv_fd(path + i, (unsigned long)fd);
i += j;
if (i + j >= PATH_LEN)
return -1;
i += j;
path[i] = '\0';
return chmod(path, mode);