PR 27459
* coff-stgo32.c (go32exe_check_format): Sanity check size of
header to avoid a buffer overflow.
+2021-02-24 Alan Modra <amodra@gmail.com>
+
+ PR 27459
+ * coff-stgo32.c (go32exe_check_format): Sanity check size of
+ header to avoid a buffer overflow.
+
2021-02-22 Alan Modra <amodra@gmail.com>
* coff-rs6000.c (_bfd_xcoff_reloc_type_lookup): Remove BFD_RELOC_16.
/* 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. */