[binutils-gdb] gas: don't recognize '8' and '9' as octal escape chars in strings

Jan Beulich via Binutils-cvs <[email protected]> Fri, 17 Jul 2026 07:25:50 +0000 (GMT)
Newsgroups gmane.comp.gnu.binutils.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Da97e7d1eb509=
f3de0aa9d89a68389b910d9f2de4

commit a97e7d1eb509f3de0aa9d89a68389b910d9f2de4
Author: Jan Beulich <[email protected]>
Date:   Fri Jul 17 09:23:35 2026 +0200

    gas: don't recognize '8' and '9' as octal escape chars in strings
   =20
    It's not clear why these were covered; it has been like this from the v=
ery
    beginning of (available) source history. Yet more oddly, an old ia64
    testcase actually uses such malformed escape sequences (which are being
    adjusted).

Diff:
---
 gas/read.c                     |  4 +---
 gas/testsuite/gas/ia64/alias.s | 10 +++++-----
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/gas/read.c b/gas/read.c
index 1a7537ba2a1..ae481007c32 100644
--- a/gas/read.c
+++ b/gas/read.c
@@ -6221,14 +6221,12 @@ next_char_of_string (void)
 	case '5':
 	case '6':
 	case '7':
-	case '8':
-	case '9':
 	  {
 	    unsigned number;
 	    int i;
=20
 	    for (i =3D 0, number =3D 0;
-		 ISDIGIT (c) && i < 3;
+		 i < 3 && c >=3D '0' && c <=3D '7';
 		 c =3D *input_line_pointer++, i++)
 	      {
 		number =3D number * 8 + c - '0';
diff --git a/gas/testsuite/gas/ia64/alias.s b/gas/testsuite/gas/ia64/alias.s
index 9ac18014fa6..d54f69fbed0 100644
--- a/gas/testsuite/gas/ia64/alias.s
+++ b/gas/testsuite/gas/ia64/alias.s
@@ -1,11 +1,11 @@
 	.section .foo,"aw","progbits"
 	.secalias .foo,"1234"
 	.secalias .foo,"1234"
-	.alias foo, "\"\80\84\""
-	.alias foo, "\"\80\84\""
+	.alias foo, "\"\100\104\""
+	.alias foo, "\"\100\104\""
 foo:
-	stringz "\"\80\84\""
+	stringz "\"\x40\x44\""
 	.secalias .foo,"1234"
 	.secalias .foo,"1234"
-	.alias foo, "\"\80\84\""
-	.alias foo, "\"\80\84\""
+	.alias foo, "\"\x40\x44\""
+	.alias foo, "\"\x40\x44\""