mach-o reloc size overflow

Message ID Y2zOkpGuKAn+V2Tk@squeak.grove.modra.org
State Repeat Merge
Headers
Series mach-o reloc size overflow |

Checks

Context Check Description
snail/binutils-gdb-check warning Git am fail log

Commit Message

Alan Modra Nov. 10, 2022, 10:12 a.m. UTC
  * mach-o.c (bfd_mach_o_canonicalize_reloc): Set bfd_error on
	multiply overflow.
  

Patch

diff --git a/bfd/mach-o.c b/bfd/mach-o.c
index 664ff44a8e7..bacb1a6252d 100644
--- a/bfd/mach-o.c
+++ b/bfd/mach-o.c
@@ -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;