[binutils-gdb] PR23940, check bounds before using

Alan Modra amodra@sourceware.org
Fri Jan 25 04:31:00 GMT 2019


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=10c172ba93dde7cb7c46982ca217e646565bf938

commit 10c172ba93dde7cb7c46982ca217e646565bf938
Author: Wu Heng <wu.heng@zte.com.cn>
Date:   Fri Jan 25 13:41:47 2019 +1030

    PR23940, check bounds before using
    
    	PR gas/23940
    	* macro.c (getstring): Check array bound before accessing.

Diff:
---
 gas/ChangeLog | 5 +++++
 gas/macro.c   | 4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/gas/ChangeLog b/gas/ChangeLog
index a930a84..50eea84 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,8 @@
+2019-01-25  Wu Heng  <wu.heng@zte.com.cn>
+
+	PR gas/23940
+	* macro.c (getstring): Check array bound before accessing.
+
 2019-01-25  Alan Modra  <amodra@gmail.com>
 
 	PR 20902
diff --git a/gas/macro.c b/gas/macro.c
index 68ae04b..5f41c13 100644
--- a/gas/macro.c
+++ b/gas/macro.c
@@ -285,8 +285,8 @@ getstring (size_t idx, sb *in, sb *acc)
 	{
 	  int nest = 0;
 	  idx++;
-	  while ((in->ptr[idx] != '>' || nest)
-		 && idx < in->len)
+	  while (idx < in->len
+		 && (in->ptr[idx] != '>' || nest))
 	    {
 	      if (in->ptr[idx] == '!')
 		{



More information about the Binutils-cvs mailing list