From 045d85dcc57fc32cd89ed695ab1d85fc5f680973 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Mon, 16 Mar 2026 21:53:30 +0000 Subject: util/nvmutil: add bound check to x_try_fdpath Signed-off-by: Leah Rowe --- util/nvmutil/nvmutil.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'util') 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); -- cgit v1.2.1