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

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