mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-23 11:39:26 +08:00
asan: som_set_reloc_info heap buffer overflow
Also a bugfix. The first time the section was read, the contents didn't supply an addend. * som.c (som_set_reloc_info): Sanity check offset. Do process contents after reading. Tidy section->contents after freeing.
This commit is contained in:
@ -5251,7 +5251,9 @@ som_set_reloc_info (unsigned char *fixup,
|
|||||||
section->contents = contents;
|
section->contents = contents;
|
||||||
deallocate_contents = 1;
|
deallocate_contents = 1;
|
||||||
}
|
}
|
||||||
else if (rptr->addend == 0)
|
if (rptr->addend == 0
|
||||||
|
&& offset - var ('L') <= section->size
|
||||||
|
&& section->size - (offset - var ('L')) >= 4)
|
||||||
rptr->addend = bfd_get_32 (section->owner,
|
rptr->addend = bfd_get_32 (section->owner,
|
||||||
(section->contents
|
(section->contents
|
||||||
+ offset - var ('L')));
|
+ offset - var ('L')));
|
||||||
@ -5269,7 +5271,10 @@ som_set_reloc_info (unsigned char *fixup,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (deallocate_contents)
|
if (deallocate_contents)
|
||||||
|
{
|
||||||
free (section->contents);
|
free (section->contents);
|
||||||
|
section->contents = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user