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

7db648
--- binutils.orig/bfd/dwarf2.c	2019-12-03 15:50:43.324118062 +0000
7db648
+++ binutils-2.30/bfd/dwarf2.c	2019-12-03 15:54:32.545489215 +0000
7db648
@@ -2803,8 +2803,8 @@ lookup_symbol_in_variable_table (struct
7db648
 
7db648
 static bfd_boolean
7db648
 find_abstract_instance_name (struct comp_unit *unit,
7db648
-			     bfd_byte *orig_info_ptr,
7db648
 			     struct attribute *attr_ptr,
7db648
+			     unsigned int recur_count,
7db648
 			     const char **pname,
7db648
 			     bfd_boolean *is_linkage)
7db648
 {
7db648
@@ -2817,6 +2817,14 @@ find_abstract_instance_name (struct comp
7db648
   struct attribute attr;
7db648
   const char *name = NULL;
7db648
 
7db648
+  if (recur_count == 100)
7db648
+    {
7db648
+      _bfd_error_handler
7db648
+       (_("DWARF error: abstract instance recursion detected"));
7db648
+      bfd_set_error (bfd_error_bad_value);
7db648
+      return FALSE;
7db648
+    }
7db648
+
7db648
   /* DW_FORM_ref_addr can reference an entry in a different CU. It
7db648
      is an offset from the .debug_info section, not the current CU.  */
7db648
   if (attr_ptr->form == DW_FORM_ref_addr)
7db648
@@ -2934,15 +2942,7 @@ find_abstract_instance_name (struct comp
7db648
 					 info_ptr, info_ptr_end);
7db648
 	      if (info_ptr == NULL)
7db648
 		break;
7db648
-	      /* It doesn't ever make sense for DW_AT_specification to
7db648
-		 refer to the same DIE.  Stop simple recursion.  */
7db648
-	      if (info_ptr == orig_info_ptr)
7db648
-		{
7db648
-		  _bfd_error_handler
7db648
-		    (_("Dwarf Error: Abstract instance recursion detected."));
7db648
-		  bfd_set_error (bfd_error_bad_value);
7db648
-		  return FALSE;
7db648
-		}
7db648
+
7db648
 	      switch (attr.name)
7db648
 		{
7db648
 		case DW_AT_name:
7db648
@@ -2956,7 +2956,7 @@ find_abstract_instance_name (struct comp
7db648
 		    }
7db648
 		  break;
7db648
 		case DW_AT_specification:
7db648
-		  if (!find_abstract_instance_name (unit, info_ptr, &attr,
7db648
+		  if (!find_abstract_instance_name (unit, &attr, recur_count + 1,
7db648
 						    pname, is_linkage))
7db648
 		    return FALSE;
7db648
 		  break;
7db648
@@ -3162,7 +3162,7 @@ scan_unit_for_symbols (struct comp_unit
7db648
 
7db648
 		case DW_AT_abstract_origin:
7db648
 		case DW_AT_specification:
7db648
-		  if (!find_abstract_instance_name (unit, info_ptr, &attr,
7db648
+		  if (!find_abstract_instance_name (unit, &attr, 0,
7db648
 						    &func->name,
7db648
 						    &func->is_linkage))
7db648
 		    goto fail;