aboutsummaryrefslogtreecommitdiff
path: root/bfd/libbfd.h
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2023-04-03 07:51:28 +0930
committerAlan Modra <amodra@gmail.com>2023-04-03 07:51:28 +0930
commit7a6efab20b469e620198d8d6a27e56d5714a0ef4 (patch)
tree51d4995404247632b417399babcfcb8e5324c042 /bfd/libbfd.h
parentf679aaa4c8fd6f72a8e2d60aba2c88127133101a (diff)
downloadfsf-binutils-gdb-7a6efab20b469e620198d8d6a27e56d5714a0ef4.zip
fsf-binutils-gdb-7a6efab20b469e620198d8d6a27e56d5714a0ef4.tar.gz
fsf-binutils-gdb-7a6efab20b469e620198d8d6a27e56d5714a0ef4.tar.bz2
asan: heap buffer overflow printing ecoff debug info file name
A case of a string section ending with an unterminated string. Fix it by allocating one more byte and making it zero. Also make functions reading the data return void* so that casts are not needed. * ecoff.c (READ): Delete type param. Allocate one extra byte to terminate string sections with a NUL. Adjust invocation. * elfxx-mips.c (READ): Likewise. * libbfd-in.h (_bfd_alloc_and_read): Return a void*. (_bfd_malloc_and_read): Likewise. * libbfd.h: Regenerate.
Diffstat (limited to 'bfd/libbfd.h')
-rw-r--r--bfd/libbfd.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index d1dc7b9..ae17717 100644
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -935,10 +935,10 @@ extern bool _bfd_link_keep_memory (struct bfd_link_info *)
#define _bfd_constant_p(v) 0
#endif
-static inline bfd_byte *
+static inline void *
_bfd_alloc_and_read (bfd *abfd, bfd_size_type asize, bfd_size_type rsize)
{
- bfd_byte *mem;
+ void *mem;
if (!_bfd_constant_p (rsize))
{
ufile_ptr filesize = bfd_get_file_size (abfd);
@@ -958,10 +958,10 @@ _bfd_alloc_and_read (bfd *abfd, bfd_size_type asize, bfd_size_type rsize)
return NULL;
}
-static inline bfd_byte *
+static inline void *
_bfd_malloc_and_read (bfd *abfd, bfd_size_type asize, bfd_size_type rsize)
{
- bfd_byte *mem;
+ void *mem;
if (!_bfd_constant_p (rsize))
{
ufile_ptr filesize = bfd_get_file_size (abfd);