_mul_overflow and get_encoded_value
A sufficiently mad compiler optimiser can take undefined behaviour according to the C standard as an opportunity to remove code. Since "data + size" might be seen to be past the end of an array, calculating such an expression is UB. _mul_overflow is infrastructure for later patches. * bucomm.h (_mul_overflow): Define. * dwarf.c (get_encoded_value): Avoid pointer UB.
This commit is contained in:
parent
7c96e6120f
commit
fc5e0925d4
3 changed files with 14 additions and 1 deletions
|
@ -178,7 +178,7 @@ get_encoded_value (unsigned char **pdata,
|
|||
unsigned int size = size_of_encoded_value (encoding);
|
||||
dwarf_vma val;
|
||||
|
||||
if (data + size >= end)
|
||||
if (data >= end || size > (size_t) (end - data))
|
||||
{
|
||||
warn (_("Encoded value extends past end of section\n"));
|
||||
* pdata = end;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue