mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-28 15:18:37 +08:00
asan: heap buffer overflow in dwarf2_directive_filename
Seen with .file 4294967289 "xxx.c" * dwarf2dbg.c (assign_file_to_slot): Catch more cases of integer overflow. Make param i an unsigned int.
This commit is contained in:
@ -679,7 +679,7 @@ get_directory_table_entry (const char *dirname,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
assign_file_to_slot (unsigned long i, const char *file, unsigned int dir)
|
assign_file_to_slot (unsigned int i, const char *file, unsigned int dir)
|
||||||
{
|
{
|
||||||
if (i >= files_allocated)
|
if (i >= files_allocated)
|
||||||
{
|
{
|
||||||
@ -687,9 +687,11 @@ assign_file_to_slot (unsigned long i, const char *file, unsigned int dir)
|
|||||||
|
|
||||||
files_allocated = i + 32;
|
files_allocated = i + 32;
|
||||||
/* Catch wraparound. */
|
/* Catch wraparound. */
|
||||||
if (files_allocated <= old)
|
if (files_allocated < old
|
||||||
|
|| files_allocated < i
|
||||||
|
|| files_allocated > UINT_MAX / sizeof (struct file_entry))
|
||||||
{
|
{
|
||||||
as_bad (_("file number %lu is too big"), (unsigned long) i);
|
as_bad (_("file number %u is too big"), i);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user