fprintf (stderr, "%s: %s: %s\n",
bfd_get_filename (abfd), names[i].secname,
bfd_errmsg (bfd_get_error ()));
+ free (shandle);
+ free (stabs);
return FALSE;
}
fprintf (stderr, "%s: %s: %s\n",
bfd_get_filename (abfd), names[i].strsecname,
bfd_errmsg (bfd_get_error ()));
+ free (shandle);
+ free (strings);
+ free (stabs);
return FALSE;
}
/* Zero terminate the strings table, just in case. */
{
shandle = start_stab (dhandle, abfd, TRUE, syms, symcount);
if (shandle == NULL)
- return FALSE;
+ {
+ free (strings);
+ free (stabs);
+ return FALSE;
+ }
}
*pfound = TRUE;
(long) (stab - stabs) / 12);
break;
}
- else
- s = concat (s, (char *) strings + strx,
- (const char *) NULL);
+
+ s = concat (s, (char *) strings + strx,
+ (const char *) NULL);
/* We have to restore the backslash, because, if
the linker is hashing stabs strings, we may
see the same string more than once. */
*p = '\\';
- if (f != NULL)
- free (f);
+ free (f);
f = s;
}
{
stab_context ();
free_saved_stabs ();
+ free (f);
+ free (shandle);
+ free (stabs);
+ free (strings);
return FALSE;
}
{
if (!probe)
error (_("Out of memory reading %u section headers\n"), num);
+ free (shdrs);
return FALSE;
}
{
if (! probe)
error (_("Out of memory reading %u section headers\n"), num);
+ free (shdrs);
return FALSE;
}
Elf_Internal_Sym * isyms = NULL;
Elf_Internal_Sym * psym;
unsigned int j;
+ elf_section_list * entry;
if (section->sh_size == 0)
{
if (esyms == NULL)
goto exit_point;
- {
- elf_section_list * entry;
-
- shndx = NULL;
- for (entry = symtab_shndx_list; entry != NULL; entry = entry->next)
- if (entry->hdr->sh_link == (unsigned long) (section - filedata->section_headers))
- {
- shndx = (Elf_External_Sym_Shndx *) get_data (NULL, filedata,
- entry->hdr->sh_offset,
- 1, entry->hdr->sh_size,
- _("symbol table section indices"));
- if (shndx == NULL)
- goto exit_point;
- /* PR17531: file: heap-buffer-overflow */
- else if (entry->hdr->sh_size / sizeof (Elf_External_Sym_Shndx) < number)
- {
- error (_("Index section %s has an sh_size of 0x%lx - expected 0x%lx\n"),
- printable_section_name (filedata, entry->hdr),
- (unsigned long) entry->hdr->sh_size,
- (unsigned long) section->sh_size);
- goto exit_point;
- }
+ shndx = NULL;
+ for (entry = symtab_shndx_list; entry != NULL; entry = entry->next)
+ {
+ if (entry->hdr->sh_link != (unsigned long) (section - filedata->section_headers))
+ continue;
+
+ if (shndx != NULL)
+ {
+ error (_("Multiple symbol table index sections associated with the same symbol section\n"));
+ free (shndx);
+ }
+
+ shndx = (Elf_External_Sym_Shndx *) get_data (NULL, filedata,
+ entry->hdr->sh_offset,
+ 1, entry->hdr->sh_size,
+ _("symbol table section indices"));
+ if (shndx == NULL)
+ goto exit_point;
+
+ /* PR17531: file: heap-buffer-overflow */
+ if (entry->hdr->sh_size / sizeof (Elf_External_Sym_Shndx) < number)
+ {
+ error (_("Index section %s has an sh_size of 0x%lx - expected 0x%lx\n"),
+ printable_section_name (filedata, entry->hdr),
+ (unsigned long) entry->hdr->sh_size,
+ (unsigned long) section->sh_size);
+ goto exit_point;
}
- }
+ }
isyms = (Elf_Internal_Sym *) cmalloc (number, sizeof (Elf_Internal_Sym));
}
exit_point:
- if (shndx != NULL)
- free (shndx);
- if (esyms != NULL)
- free (esyms);
+ free (shndx);
+ free (esyms);
if (num_syms_return != NULL)
* num_syms_return = isyms == NULL ? 0 : number;
Elf_Internal_Sym * isyms = NULL;
Elf_Internal_Sym * psym;
unsigned int j;
+ elf_section_list * entry;
if (section->sh_size == 0)
{
if (!esyms)
goto exit_point;
- {
- elf_section_list * entry;
-
- shndx = NULL;
- for (entry = symtab_shndx_list; entry != NULL; entry = entry->next)
- if (entry->hdr->sh_link == (unsigned long) (section - filedata->section_headers))
- {
- shndx = (Elf_External_Sym_Shndx *) get_data (NULL, filedata,
- entry->hdr->sh_offset,
- 1, entry->hdr->sh_size,
- _("symbol table section indices"));
- if (shndx == NULL)
- goto exit_point;
- /* PR17531: file: heap-buffer-overflow */
- else if (entry->hdr->sh_size / sizeof (Elf_External_Sym_Shndx) < number)
- {
- error (_("Index section %s has an sh_size of 0x%lx - expected 0x%lx\n"),
- printable_section_name (filedata, entry->hdr),
- (unsigned long) entry->hdr->sh_size,
- (unsigned long) section->sh_size);
- goto exit_point;
- }
+ shndx = NULL;
+ for (entry = symtab_shndx_list; entry != NULL; entry = entry->next)
+ {
+ if (entry->hdr->sh_link != (unsigned long) (section - filedata->section_headers))
+ continue;
+
+ if (shndx != NULL)
+ {
+ error (_("Multiple symbol table index sections associated with the same symbol section\n"));
+ free (shndx);
}
- }
+
+ shndx = (Elf_External_Sym_Shndx *) get_data (NULL, filedata,
+ entry->hdr->sh_offset,
+ 1, entry->hdr->sh_size,
+ _("symbol table section indices"));
+ if (shndx == NULL)
+ goto exit_point;
+
+ /* PR17531: file: heap-buffer-overflow */
+ if (entry->hdr->sh_size / sizeof (Elf_External_Sym_Shndx) < number)
+ {
+ error (_("Index section %s has an sh_size of 0x%lx - expected 0x%lx\n"),
+ printable_section_name (filedata, entry->hdr),
+ (unsigned long) entry->hdr->sh_size,
+ (unsigned long) section->sh_size);
+ goto exit_point;
+ }
+ }
isyms = (Elf_Internal_Sym *) cmalloc (number, sizeof (Elf_Internal_Sym));
}
exit_point:
- if (shndx != NULL)
- free (shndx);
- if (esyms != NULL)
- free (esyms);
+ free (shndx);
+ free (esyms);
if (num_syms_return != NULL)
* num_syms_return = isyms == NULL ? 0 : number;
section.sh_entsize = sizeof (Elf64_External_Sym);
section.sh_name = filedata->string_table_length;
+ if (dynamic_symbols != NULL)
+ {
+ error (_("Multiple dynamic symbol table sections found\n"));
+ free (dynamic_symbols);
+ }
dynamic_symbols = GET_ELF_SYMBOLS (filedata, §ion, & num_dynamic_syms);
if (num_dynamic_syms < 1)
{
continue;
}
+ if (dynamic_strings != NULL)
+ {
+ error (_("Multiple dynamic string tables found\n"));
+ free (dynamic_strings);
+ }
+
dynamic_strings = (char *) get_data (NULL, filedata, offset, 1,
str_tab_len,
_("dynamic string table"));
dynamic_strings_length = dynamic_strings == NULL ? 0 : str_tab_len;
- break;
}
}
if (!extsyminfo)
return FALSE;
+ if (dynamic_syminfo != NULL)
+ {
+ error (_("Multiple dynamic symbol information sections found\n"));
+ free (dynamic_syminfo);
+ }
dynamic_syminfo = (Elf_Internal_Syminfo *) malloc (syminsz);
if (dynamic_syminfo == NULL)
{