[binutils-gdb] PR26506 UBSAN: elf32-xtensa.c:3203 null pointer memcpy

Alan Modra amodra@sourceware.org
Wed Aug 26 13:55:27 GMT 2020


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=252e57fdd41118855f67ada7785b4ce3d5e61ad3

commit 252e57fdd41118855f67ada7785b4ce3d5e61ad3
Author: Alan Modra <amodra@gmail.com>
Date:   Wed Aug 26 20:20:11 2020 +0930

    PR26506 UBSAN: elf32-xtensa.c:3203 null pointer memcpy
    
            PR 26506
            * elf32-xtensa.c (elf_xtensa_combine_prop_entries): Return early
            when section is empty.

Diff:
---
 bfd/ChangeLog      | 6 ++++++
 bfd/elf32-xtensa.c | 3 +++
 2 files changed, 9 insertions(+)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 1cd7943abc3..765188d303c 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2020-08-26  Alan Modra  <amodra@gmail.com>
+
+	PR 26506
+	* elf32-xtensa.c (elf_xtensa_combine_prop_entries): Return early
+	when section is empty.
+
 2020-08-26  Alan Modra  <amodra@gmail.com>
 
 	PR 26498
diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c
index 65c6ceb3794..5184fbf1be7 100644
--- a/bfd/elf32-xtensa.c
+++ b/bfd/elf32-xtensa.c
@@ -3117,6 +3117,9 @@ elf_xtensa_combine_prop_entries (bfd *output_bfd,
   int n, m, num;
 
   section_size = sxtlit->size;
+  if (section_size == 0)
+    return 0;
+
   BFD_ASSERT (section_size % 8 == 0);
   num = section_size / 8;


More information about the Binutils-cvs mailing list