aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-08-26 14:18:53 +0930
committerAlan Modra <amodra@gmail.com>2020-08-26 23:23:44 +0930
commit9863cbb7bd3495107a5b1b4d887c95d859c9a35e (patch)
treef4e17967965210e6898d5a43bf05568281e984f8 /bfd
parentc01de193638c9022411ae0542a457b9d68723013 (diff)
downloadgdb-9863cbb7bd3495107a5b1b4d887c95d859c9a35e.zip
gdb-9863cbb7bd3495107a5b1b4d887c95d859c9a35e.tar.gz
gdb-9863cbb7bd3495107a5b1b4d887c95d859c9a35e.tar.bz2
PR26418 UBSAN: cache.c:386 null pointer fwrite
PR 26418 * ecofflink.c (WRITE): Don't write size 0 chunks.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog5
-rw-r--r--bfd/ecofflink.c10
2 files changed, 11 insertions, 4 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index c296f6d..2fd2321 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,10 @@
2020-08-26 Alan Modra <amodra@gmail.com>
+ PR 26418
+ * ecofflink.c (WRITE): Don't write size 0 chunks.
+
+2020-08-26 Alan Modra <amodra@gmail.com>
+
* bfdio.c (bfd_get_file_size): Don't segv on NULL adata.
2020-08-26 Alan Modra <amodra@gmail.com>
diff --git a/bfd/ecofflink.c b/bfd/ecofflink.c
index e7b35f6..7c9a7ae 100644
--- a/bfd/ecofflink.c
+++ b/bfd/ecofflink.c
@@ -1489,10 +1489,12 @@ bfd_ecoff_write_debug (bfd *abfd,
return FALSE;
#define WRITE(ptr, count, size, offset) \
- BFD_ASSERT (symhdr->offset == 0 \
- || (bfd_vma) bfd_tell (abfd) == symhdr->offset); \
- if (bfd_bwrite (debug->ptr, (bfd_size_type) size * symhdr->count, abfd)\
- != size * symhdr->count) \
+ BFD_ASSERT (symhdr->offset == 0 \
+ || (bfd_vma) bfd_tell (abfd) == symhdr->offset); \
+ if (size != 0 \
+ && bfd_bwrite (debug->ptr, \
+ (bfd_size_type) size * symhdr->count, \
+ abfd) != size * symhdr->count) \
return FALSE;
WRITE (line, cbLine, sizeof (unsigned char), cbLineOffset);