[binutils-gdb] Fix illegal memory access parsing a corrupt MACH-O format file.

Nick Clifton nickc@sourceware.org
Fri Apr 30 13:31:32 GMT 2021


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

commit d1fbc3ba09fb2e79acf633df29ccbe9285624419
Author: Nick Clifton <nickc@redhat.com>
Date:   Fri Apr 30 14:31:03 2021 +0100

    Fix illegal memory access parsing a corrupt MACH-O format file.
    
            PR 27801
            * mach-o.c (bfd_mach_o_core_fetch_environment): Use bfd_get_32 to
            read 32-bit value.

Diff:
---
 bfd/ChangeLog | 6 ++++++
 bfd/mach-o.c  | 3 ++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index cd9b1b38607..c5a617cef97 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2021-04-30  Nick Clifton  <nickc@redhat.com>
+
+	PR 27801
+	* mach-o.c (bfd_mach_o_core_fetch_environment): Use bfd_get_32 to
+	read 32-bit value.
+
 2021-04-30  Nick Clifton  <nickc@redhat.com>
 
 	PR 27799
diff --git a/bfd/mach-o.c b/bfd/mach-o.c
index 60121c4ef47..ff18ded23d5 100644
--- a/bfd/mach-o.c
+++ b/bfd/mach-o.c
@@ -5931,7 +5931,8 @@ bfd_mach_o_core_fetch_environment (bfd *abfd,
 		{
 		  unsigned long val;
 
-		  val = *((unsigned long *) (buf + size - offset));
+		  val = bfd_get_32(abfd, buf + size - offset);
+
 		  if (! found_nonnull)
 		    {
 		      if (val != 0)


More information about the Binutils-cvs mailing list