* go32 sanity check
@ 2022-11-18 1:02 Alan Modra
0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2022-11-18 1:02 UTC (permalink / raw)
To: binutils
* coff-stgo32 (go32exe_check_format): Sanity check stubsize against
filesize before malloc.
diff --git a/bfd/coff-stgo32.c b/bfd/coff-stgo32.c
index cb0df389375..17271753a7a 100644
--- a/bfd/coff-stgo32.c
+++ b/bfd/coff-stgo32.c
@@ -291,6 +291,10 @@ go32exe_check_format (bfd *abfd)
if (last_page_size != 0)
stubsize += last_page_size - 512;
+ ufile_ptr filesize = bfd_get_file_size (abfd);
+ if (filesize != 0 && stubsize > filesize)
+ goto fail_format;
+
/* Save now the stub to be used later. Put the stub data to a temporary
location first as tdata still does not exist. It may not even
be ever created if we are just checking the file format of ABFD. */
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-11-18 1:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-18 1:02 go32 sanity check 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).