demand_copy_C_string NUL check
Alan Modra
amodra@gmail.com
Tue Feb 16 09:05:37 GMT 2021
Making sure strings don't contain '\0' can't be that important; This
bug has been around since 1991.
* read.c (demand_copy_C_string): Really check for embedded zeros.
diff --git a/gas/read.c b/gas/read.c
index ede811b0a0..3e76065328 100644
--- a/gas/read.c
+++ b/gas/read.c
@@ -5743,12 +5743,12 @@ demand_copy_C_string (int *len_pointer)
for (len = *len_pointer; len > 0; len--)
{
- if (*s == 0)
+ if (s[len - 1] == 0)
{
s = 0;
- len = 1;
*len_pointer = 0;
as_bad (_("this string may not contain \'\\0\'"));
+ break;
}
}
}
--
Alan Modra
Australia Development Lab, IBM
More information about the Binutils
mailing list