diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-03-16 21:53:30 +0000 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-03-16 21:53:30 +0000 |
| commit | 045d85dcc57fc32cd89ed695ab1d85fc5f680973 (patch) | |
| tree | 899730a38db4d348f24d770ff4998a3b523707c7 /util/nvmutil/nvmutil.c | |
| parent | 841fe878f3e9eed6a3ada04a20daa45eec8cd935 (diff) | |
util/nvmutil: add bound check to x_try_fdpath
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/nvmutil/nvmutil.c')
| -rw-r--r-- | util/nvmutil/nvmutil.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index 66f18300..b40a0910 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -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); |
