* PR27459, segmentation fault in go32exe_check_format
@ 2021-02-24 2:26 Alan Modra
0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2021-02-24 2:26 UTC (permalink / raw)
To: binutils
PR 27459
* coff-stgo32.c (go32exe_check_format): Sanity check size of
header to avoid a buffer overflow.
diff --git a/bfd/coff-stgo32.c b/bfd/coff-stgo32.c
index 7ae9419772..7593b62e8e 100644
--- a/bfd/coff-stgo32.c
+++ b/bfd/coff-stgo32.c
@@ -304,7 +304,9 @@ go32exe_check_format (bfd *abfd)
/* Confirm that this is a go32stub. */
header_end = H_GET_16 (abfd, filehdr_dos.e_cparhdr) * 16UL;
- if (! CONST_STRNEQ (go32exe_temp_stub + header_end, "go32stub"))
+ if (go32exe_temp_stub_size < header_end
+ || go32exe_temp_stub_size - header_end < sizeof "go32stub" - 1
+ || !CONST_STRNEQ (go32exe_temp_stub + header_end, "go32stub"))
goto fail_format;
/* Set origin to where the COFF header starts and seek there. */
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-02-24 2:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-24 2:26 PR27459, segmentation fault in go32exe_check_format Alan Modra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).