Prevent a potential use-after-fee memory corruption bug in the linker (for PE format files).
PR 25993 * emultempl/pe.em (_after_open): Check for duplicate filename pointers before renaming the dll. * emultempl/pep.em (_after_open): Likewise.
This commit is contained in:
parent
d402189f2f
commit
5e365e474b
@ -1,3 +1,10 @@
|
||||
2020-05-18 Nick Clifton <nickc@redhat.com>
|
||||
|
||||
PR 25993
|
||||
* emultempl/pe.em (_after_open): Check for duplicate filename
|
||||
pointers before renaming the dll.
|
||||
* emultempl/pep.em (_after_open): Likewise.
|
||||
|
||||
2020-05-13 Nick Clifton <nickc@redhat.com>
|
||||
|
||||
PR 25979
|
||||
|
@ -1655,6 +1655,19 @@ gld_${EMULATION_NAME}_after_open (void)
|
||||
else /* sentinel */
|
||||
seq = 'c';
|
||||
|
||||
|
||||
/* PR 25993: It is possible that is->the_bfd-filename == is->filename.
|
||||
In which case calling bfd_set_filename on one will free the memory
|
||||
pointed to by the other. */
|
||||
if (is->filename == is->the_bfd->filename)
|
||||
{
|
||||
new_name = xmalloc (strlen (is->filename) + 3);
|
||||
sprintf (new_name, "%s.%c", is->filename, seq);
|
||||
bfd_set_filename (is->the_bfd, new_name);
|
||||
is->filename = new_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_name = xmalloc (strlen (is->the_bfd->filename) + 3);
|
||||
sprintf (new_name, "%s.%c", is->the_bfd->filename, seq);
|
||||
bfd_set_filename (is->the_bfd, new_name);
|
||||
@ -1666,6 +1679,7 @@ gld_${EMULATION_NAME}_after_open (void)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
/* The following chunk of code tries to identify jump stubs in
|
||||
|
@ -1623,6 +1623,18 @@ gld_${EMULATION_NAME}_after_open (void)
|
||||
else /* sentinel */
|
||||
seq = 'c';
|
||||
|
||||
/* PR 25993: It is possible that is->the_bfd-filename == is->filename.
|
||||
In which case calling bfd_set_filename on one will free the memory
|
||||
pointed to by the other. */
|
||||
if (is->filename == is->the_bfd->filename)
|
||||
{
|
||||
new_name = xmalloc (strlen (is->filename) + 3);
|
||||
sprintf (new_name, "%s.%c", is->filename, seq);
|
||||
bfd_set_filename (is->the_bfd, new_name);
|
||||
is->filename = new_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_name = xmalloc (strlen (is->the_bfd->filename) + 3);
|
||||
sprintf (new_name, "%s.%c", is->the_bfd->filename, seq);
|
||||
bfd_set_filename (is->the_bfd, new_name);
|
||||
@ -1635,6 +1647,7 @@ gld_${EMULATION_NAME}_after_open (void)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gld_${EMULATION_NAME}_before_allocation (void)
|
||||
|
Loading…
Reference in New Issue
Block a user