Blame SOURCES/binutils-CVE-2019-17450.patch

0c74e2
--- binutils.orig/bfd/dwarf2.c	2019-11-13 11:49:52.211121564 +0000
0c74e2
+++ binutils-2.33.1/bfd/dwarf2.c	2019-11-13 11:53:26.991423055 +0000
0c74e2
@@ -2813,8 +2813,8 @@ static bfd_boolean comp_unit_maybe_decod
0c74e2
 
0c74e2
 static bfd_boolean
0c74e2
 find_abstract_instance (struct comp_unit *   unit,
0c74e2
-			bfd_byte *           orig_info_ptr,
0c74e2
 			struct attribute *   attr_ptr,
0c74e2
+			unsigned int         recur_count,
0c74e2
 			const char **        pname,
0c74e2
 			bfd_boolean *        is_linkage,
0c74e2
 			char **              filename_ptr,
0c74e2
@@ -2829,6 +2829,14 @@ find_abstract_instance (struct comp_unit
0c74e2
   struct attribute attr;
0c74e2
   const char *name = NULL;
0c74e2
 
0c74e2
+  if (recur_count == 100)
0c74e2
+    {
0c74e2
+      _bfd_error_handler
0c74e2
+       (_("DWARF error: abstract instance recursion detected"));
0c74e2
+      bfd_set_error (bfd_error_bad_value);
0c74e2
+      return FALSE;
0c74e2
+    }
0c74e2
+
0c74e2
   /* DW_FORM_ref_addr can reference an entry in a different CU. It
0c74e2
      is an offset from the .debug_info section, not the current CU.  */
0c74e2
   if (attr_ptr->form == DW_FORM_ref_addr)
0c74e2
@@ -2962,15 +2970,7 @@ find_abstract_instance (struct comp_unit
0c74e2
 					 info_ptr, info_ptr_end);
0c74e2
 	      if (info_ptr == NULL)
0c74e2
 		break;
0c74e2
-	      /* It doesn't ever make sense for DW_AT_specification to
0c74e2
-		 refer to the same DIE.  Stop simple recursion.  */
0c74e2
-	      if (info_ptr == orig_info_ptr)
0c74e2
-		{
0c74e2
-		  _bfd_error_handler
0c74e2
-		    (_("DWARF error: abstract instance recursion detected"));
0c74e2
-		  bfd_set_error (bfd_error_bad_value);
0c74e2
-		  return FALSE;
0c74e2
-		}
0c74e2
+
0c74e2
 	      switch (attr.name)
0c74e2
 		{
0c74e2
 		case DW_AT_name:
0c74e2
@@ -2984,7 +2984,7 @@ find_abstract_instance (struct comp_unit
0c74e2
 		    }
0c74e2
 		  break;
0c74e2
 		case DW_AT_specification:
0c74e2
-		  if (!find_abstract_instance (unit, info_ptr, &attr,
0c74e2
+		  if (!find_abstract_instance (unit, &attr, recur_count + 1,
0c74e2
 					       &name, is_linkage,
0c74e2
 					       filename_ptr, linenumber_ptr))
0c74e2
 		    return FALSE;
0c74e2
@@ -3200,7 +3200,7 @@ scan_unit_for_symbols (struct comp_unit
0c74e2
 
0c74e2
 		case DW_AT_abstract_origin:
0c74e2
 		case DW_AT_specification:
0c74e2
-		  if (!find_abstract_instance (unit, info_ptr, &attr,
0c74e2
+		  if (!find_abstract_instance (unit, &attr, 0,
0c74e2
 					       &func->name,
0c74e2
 					       &func->is_linkage,
0c74e2
 					       &func->file,