forked from Imagelibrary/binutils-gdb
Fix unbounded stack usage warning inside the SAFE_BYTE_GET macro.
PR 19851 binutils * dwarf.c (SAFE_BYTE_GET): Replace local dynamic array allocation with run time size check.
This commit is contained in:
@@ -317,8 +317,13 @@ read_uleb128 (unsigned char * data,
|
||||
#define SAFE_BYTE_GET(VAL, PTR, AMOUNT, END) \
|
||||
do \
|
||||
{ \
|
||||
int dummy [sizeof (VAL) < (AMOUNT) ? -1 : 1] ATTRIBUTE_UNUSED ; \
|
||||
unsigned int amount = (AMOUNT); \
|
||||
if (sizeof (VAL) < amount) \
|
||||
{ \
|
||||
error (_("internal error: attempt to read %d bytes of data in to %d sized variable"),\
|
||||
amount, (int) sizeof (VAL)); \
|
||||
amount = sizeof (VAL); \
|
||||
} \
|
||||
if (((PTR) + amount) >= (END)) \
|
||||
{ \
|
||||
if ((PTR) < (END)) \
|
||||
|
||||
Reference in New Issue
Block a user