From 1b2ed39c3a7ee2870f3d16a510d31e8d5916afbc Mon Sep 17 00:00:00 2001 From: Wu Heng Date: Fri, 4 Jan 2019 16:18:59 +0000 Subject: Fix potential buffer overrun whilst scanning macro strings. PR 24010 * macro.c (get_any_string): Check for end of input whilst scanning for separators. --- gas/macro.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gas/macro.c') diff --git a/gas/macro.c b/gas/macro.c index a1a2323c5e2..68ae04b010b 100644 --- a/gas/macro.c +++ b/gas/macro.c @@ -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) -- cgit v1.2.1