Skip to contentSkip to conversation

util_lib/elf_info.c: fix a warning

PATCH Applied Baoquan He 2 participants 2 messages Mar 21, 2024 – Mar 22, 2024

Subsystems (2)
lore
Share & tools
lore

Baoquan He

author
#0 lore raw

PATCH 1/1 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.

---
 util_lib/elf_info.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
util_lib/elf_info.c +1 -1
index ce71c6055c3a..7ca9870bfca0 100644
@@ -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;
Signature · 7 lines
2.41.0


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Applied
#1 lore raw
Quoted 11 lines · 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];
      |              ^~~~~~~~
Quoted 5 lines

---------------------

Fix it to avoid oob access of array.

Thanks, applied.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec