From d1fbc3ba09fb2e79acf633df29ccbe9285624419 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Fri, 30 Apr 2021 14:31:03 +0100 Subject: [PATCH] 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. --- 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 + + 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 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) -- 2.30.2