Fix potential buffer overrun whilst scanning macro strings.
authorWu Heng <wu.heng@zte.com.cn>
Fri, 4 Jan 2019 16:18:59 +0000 (16:18 +0000)
committerNick Clifton <nickc@redhat.com>
Fri, 4 Jan 2019 16:18:59 +0000 (16:18 +0000)
PR 24010
* macro.c (get_any_string): Check for end of input whilst scanning
for separators.

gas/ChangeLog
gas/macro.c

index 3caf7052a7a1ae859e9425d376ca2a89a2528d7c..e0a80c09c59818447f17185b720bfd4650bb8921 100644 (file)
@@ -1,3 +1,9 @@
+2019-01-04  Wu Heng  <wu.heng@zte.com.cn>
+
+       PR 24010
+       * macro.c (get_any_string): Check for end of input whilst scanning
+       for separators.
+
 2019-01-04  Wu Heng  <wu.heng@zte.com.cn>
 
        PR 24009
index a1a2323c5e2d47f0004038bcecdd855047915fcc..68ae04b010b5ee87feabed517e6c871a72e8a7ff 100644 (file)
@@ -369,7 +369,7 @@ get_any_string (size_t idx, sb *in, sb *out)
     {
       if (in->len > idx + 2 && in->ptr[idx + 1] == '\'' && ISBASE (in->ptr[idx]))
        {
-         while (!ISSEP (in->ptr[idx]))
+         while (idx < in->len && !ISSEP (in->ptr[idx]))
            sb_add_char (out, in->ptr[idx++]);
        }
       else if (in->ptr[idx] == '%' && macro_alternate)