summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBaoquan He <bhe@redhat.com>2024-03-21 15:30:37 +0800
committerSimon Horman <horms@kernel.org>2024-03-22 20:45:54 +0000
commit623ceb333c18df6f75d46940d9e1934004bc8ae0 (patch)
tree196b3d63bf4df212415ed4618658cdb019bf5681
parent9d9cf8de8b2ad8273861a30476a46f34cd34871a (diff)
downloadkexec-tools-623ceb333c18df6f75d46940d9e1934004bc8ae0.tar.gz
util_lib/elf_info.c: fix a warning
There's a incorrect array operation in function scan_vmcoreinfo(), it will cause below warning message. ----------------------- util_lib/elf_info.c: In function ‘scan_vmcoreinfo’: util_lib/elf_info.c:360:43: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] 360 | temp_buf[len + 1] = '\0'; | ~~~~~~~~~~~~~~~~~~^~~~~~ util_lib/elf_info.c:319:14: note: at offset 1024 into destination object ‘temp_buf’ of size 1024 319 | char temp_buf[1024]; | ^~~~~~~~ --------------------- Fix it to avoid oob access of array. Signed-off-by: Baoquan He <bhe@redhat.com> Signed-off-by: Simon Horman <horms@kernel.org>
-rw-r--r--util_lib/elf_info.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/util_lib/elf_info.c b/util_lib/elf_info.c
index ce71c605..7ca9870b 100644
--- a/util_lib/elf_info.c
+++ b/util_lib/elf_info.c
@@ -357,7 +357,7 @@ void scan_vmcoreinfo(char *start, size_t size)
if (len >= sizeof(temp_buf))
len = sizeof(temp_buf) - 1;
strncpy(temp_buf, pos, len);
- temp_buf[len + 1] = '\0';
+ temp_buf[len] = '\0';
pos = temp_buf;
len = len + 1;