* [PATCH] util_lib/elf_info.c: fix a warning
@ 2024-03-21 7:30 Baoquan He
2024-03-22 21:09 ` Simon Horman
0 siblings, 1 reply; 2+ messages in thread
From: Baoquan He @ 2024-03-21 7:30 UTC (permalink / raw)
To: kexec; +Cc: horms, Baoquan He
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>
---
util_lib/elf_info.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/util_lib/elf_info.c b/util_lib/elf_info.c
index ce71c6055c3a..7ca9870bfca0 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;
--
2.41.0
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] util_lib/elf_info.c: fix a warning
2024-03-21 7:30 [PATCH] util_lib/elf_info.c: fix a warning Baoquan He
@ 2024-03-22 21:09 ` Simon Horman
0 siblings, 0 replies; 2+ messages in thread
From: Simon Horman @ 2024-03-22 21:09 UTC (permalink / raw)
To: Baoquan He; +Cc: kexec
On Thu, Mar 21, 2024 at 03:30:37PM +0800, Baoquan He wrote:
> 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>
Thanks, applied.
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-03-22 21:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-21 7:30 [PATCH] util_lib/elf_info.c: fix a warning Baoquan He
2024-03-22 21:09 ` Simon Horman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox