Bug 23940

Summary: check index is within bounds before using it
Product: binutils Reporter: wuheng <wu.heng>
Component: gasAssignee: Alan Modra <amodra>
Status: ASSIGNED ---    
Severity: normal CC: ppluzhnikov, wu.heng
Priority: P2    
Version: 2.32   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed: 2019-01-25 00:00:00
Attachments: check bounds befroe using
bug file to reproduce the error

Description wuheng 2018-11-30 09:19:34 UTC
Created attachment 11422 [details]
check bounds befroe using

The var "idx" should be checked before using in function "getstring" gas/macro.c:288.

	  while ((in->ptr[idx] != '>' || nest)
		 && idx < in->len)

The out of bounds judgment should be in front of using.
Comment 1 wuheng 2018-12-04 12:14:42 UTC
Created attachment 11429 [details]
bug file to reproduce the error

the bound of char* "in->ptr" should be checked first before using!
Comment 2 cvs-commit@gcc.gnu.org 2019-01-25 04:31:34 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:


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.