macro.c:871 heap-buffer-overflow

Message ID Z2yNmyaHbxBmKtMX@squeak.grove.modra.org
State New
Headers
Series macro.c:871 heap-buffer-overflow |

Commit Message

Alan Modra Dec. 25, 2024, 10:56 p.m. UTC
  PR 32391 commit 9f2e3c21f6 fallout again.  Also fix another 'macro'
may be used uninitialized.
  

Patch

diff --git a/gas/macro.c b/gas/macro.c
index 3d5a9f14341..ded0645be8d 100644
--- a/gas/macro.c
+++ b/gas/macro.c
@@ -868,7 +868,7 @@  sub_actual (size_t start, sb *in, sb *t, struct htab *formal_hash,
 	  /* The parent's FORMALs might contain parameters that need further
 	     substitution.  See gas/testsuite/gas/arm/macro-vld1.s for an
 	     example of this.  */
-	  if (strchr (add->ptr, '\\'))
+	  if (memchr (add->ptr, '\\', add->len))
 	    {
 	      sb newadd;
 
@@ -1485,7 +1485,7 @@  delete_macro (const char *name)
 	}
     }
 
-  if (macro == NULL)
+  if (j < 0)
     as_warn (_("Attempt to purge non-existing macro `%s'"), copy);
 
   free (copy);