]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
go32 sanity check
authorAlan Modra <amodra@gmail.com>
Wed, 16 Nov 2022 21:03:55 +0000 (07:33 +1030)
committerAlan Modra <amodra@gmail.com>
Fri, 18 Nov 2022 01:01:17 +0000 (11:31 +1030)
* coff-stgo32 (go32exe_check_format): Sanity check stubsize against
filesize before malloc.

bfd/coff-stgo32.c

index cb0df3893750ffa85f4c49ceba1d739d55281dfc..17271753a7ab51b4d9624f32d5f2e1c87b701cb2 100644 (file)
@@ -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.  */