mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-19 17:18:24 +08:00
Fix an attempt to free a static pointer when using objcopy's symbol addition feature.
PR 25220 * objcopy.c (empty_name): New variable. (need_sym_before): Prevent an attempt to free a static variable. (filter_symbols): Avoid strcmp test by checking for pointer equality.
This commit is contained in:
@ -1,3 +1,11 @@
|
|||||||
|
2020-01-09 Nick Clifton <nickc@redhat.com>
|
||||||
|
|
||||||
|
PR 25220
|
||||||
|
* objcopy.c (empty_name): New variable.
|
||||||
|
(need_sym_before): Prevent an attempt to free a static variable.
|
||||||
|
(filter_symbols): Avoid strcmp test by checking for pointer
|
||||||
|
equality.
|
||||||
|
|
||||||
2020-01-09 Nick Clifton <nickc@redhat.com>
|
2020-01-09 Nick Clifton <nickc@redhat.com>
|
||||||
|
|
||||||
* po/zh_TW.po: Updated Traditional Chinese translation.
|
* po/zh_TW.po: Updated Traditional Chinese translation.
|
||||||
|
@ -68,7 +68,7 @@ struct addsym_node
|
|||||||
long symval;
|
long symval;
|
||||||
flagword flags;
|
flagword flags;
|
||||||
char * section;
|
char * section;
|
||||||
char * othersym;
|
const char * othersym;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct section_rename
|
typedef struct section_rename
|
||||||
@ -808,7 +808,7 @@ parse_flags (const char *s)
|
|||||||
string can't be parsed. */
|
string can't be parsed. */
|
||||||
|
|
||||||
static flagword
|
static flagword
|
||||||
parse_symflags (const char *s, char **other)
|
parse_symflags (const char *s, const char **other)
|
||||||
{
|
{
|
||||||
flagword ret;
|
flagword ret;
|
||||||
const char *snext;
|
const char *snext;
|
||||||
@ -1453,6 +1453,9 @@ is_hidden_symbol (asymbol *sym)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Empty name is hopefully never a valid symbol name. */
|
||||||
|
static const char * empty_name = "";
|
||||||
|
|
||||||
static bfd_boolean
|
static bfd_boolean
|
||||||
need_sym_before (struct addsym_node **node, const char *sym)
|
need_sym_before (struct addsym_node **node, const char *sym)
|
||||||
{
|
{
|
||||||
@ -1464,10 +1467,12 @@ need_sym_before (struct addsym_node **node, const char *sym)
|
|||||||
{
|
{
|
||||||
if (!ptr->othersym)
|
if (!ptr->othersym)
|
||||||
break;
|
break;
|
||||||
|
if (ptr->othersym == empty_name)
|
||||||
|
continue;
|
||||||
else if (strcmp (ptr->othersym, sym) == 0)
|
else if (strcmp (ptr->othersym, sym) == 0)
|
||||||
{
|
{
|
||||||
free (ptr->othersym);
|
free ((char *) ptr->othersym);
|
||||||
ptr->othersym = ""; /* Empty name is hopefully never a valid symbol name. */
|
ptr->othersym = empty_name;
|
||||||
*node = ptr;
|
*node = ptr;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -1695,7 +1700,7 @@ filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms,
|
|||||||
{
|
{
|
||||||
if (ptr->othersym)
|
if (ptr->othersym)
|
||||||
{
|
{
|
||||||
if (strcmp (ptr->othersym, ""))
|
if (ptr->othersym != empty_name)
|
||||||
fatal (_("'before=%s' not found"), ptr->othersym);
|
fatal (_("'before=%s' not found"), ptr->othersym);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user