Blame SOURCES/binutils-CVE-2018-8945.patch

381f6c
diff -rup binutils.orig/bfd/elf-attrs.c binutils-2.30/bfd/elf-attrs.c
381f6c
--- binutils.orig/bfd/elf-attrs.c	2018-05-17 14:14:04.341805666 +0100
381f6c
+++ binutils-2.30/bfd/elf-attrs.c	2018-05-17 14:15:19.729952453 +0100
381f6c
@@ -438,6 +438,14 @@ _bfd_elf_parse_attributes (bfd *abfd, El
381f6c
   /* PR 17512: file: 2844a11d.  */
381f6c
   if (hdr->sh_size == 0)
381f6c
     return;
381f6c
+  if (hdr->sh_size > bfd_get_file_size (abfd))
381f6c
+    {
381f6c
+      _bfd_error_handler (_("%pB: error: attribute section '%pA' too big: %#llx"),
381f6c
+			  abfd, hdr->bfd_section, (long long) hdr->sh_size);
381f6c
+      bfd_set_error (bfd_error_invalid_operation);
381f6c
+      return;
381f6c
+    }
381f6c
+
381f6c
   contents = (bfd_byte *) bfd_malloc (hdr->sh_size + 1);
381f6c
   if (!contents)
381f6c
     return;
381f6c
diff -rup binutils.orig/bfd/elf.c binutils-2.30/bfd/elf.c
381f6c
--- binutils.orig/bfd/elf.c	2018-05-17 14:14:04.326805836 +0100
381f6c
+++ binutils-2.30/bfd/elf.c	2018-05-17 14:15:59.412503342 +0100
381f6c
@@ -298,6 +298,7 @@ bfd_elf_get_str_section (bfd *abfd, unsi
381f6c
       /* Allocate and clear an extra byte at the end, to prevent crashes
381f6c
 	 in case the string table is not terminated.  */
381f6c
       if (shstrtabsize + 1 <= 1
381f6c
+	  || shstrtabsize > bfd_get_file_size (abfd)
381f6c
 	  || bfd_seek (abfd, offset, SEEK_SET) != 0
381f6c
 	  || (shstrtab = (bfd_byte *) bfd_alloc (abfd, shstrtabsize + 1)) == NULL)
381f6c
 	shstrtab = NULL;