mach-o reloc size overflow
authorAlan Modra <amodra@gmail.com>
Wed, 9 Nov 2022 23:07:36 +0000 (09:37 +1030)
committerAlan Modra <amodra@gmail.com>
Thu, 10 Nov 2022 09:59:03 +0000 (20:29 +1030)
* mach-o.c (bfd_mach_o_canonicalize_reloc): Set bfd_error on
multiply overflow.

bfd/mach-o.c

index 664ff44a8e7ce288eca5d16cf4ef28a54cdb2c6b..bacb1a6252dc5010a98e617dceb27878ec5ae8a2 100644 (file)
@@ -1663,7 +1663,10 @@ bfd_mach_o_canonicalize_reloc (bfd *abfd, asection *asect,
       size_t amt;
 
       if (_bfd_mul_overflow (asect->reloc_count, sizeof (arelent), &amt))
-       return -1;
+       {
+         bfd_set_error (bfd_error_file_too_big);
+         return -1;
+       }
       res = bfd_malloc (amt);
       if (res == NULL)
        return -1;