aboutsummaryrefslogtreecommitdiff
path: root/bfd/libbfd-in.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-in.h
parentf679aaa4c8fd6f72a8e2d60aba2c88127133101a (diff)
downloadgdb-7a6efab20b469e620198d8d6a27e56d5714a0ef4.zip
gdb-7a6efab20b469e620198d8d6a27e56d5714a0ef4.tar.gz
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-in.h')
-rw-r--r--bfd/libbfd-in.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h
index 1c9f34b..561cef1 100644
--- a/bfd/libbfd-in.h
+++ b/bfd/libbfd-in.h
@@ -929,10 +929,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);
@@ -952,10 +952,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);