* readelf.c (dump_section_as_strings): Free memory on error exit.
(dump_section_as_bytes, process_notes_at): Likewise.
(get_build_id): Free enote.
+2020-03-14 Alan Modra <amodra@gmail.com>
+
+ * readelf.c (dump_section_as_strings): Free memory on error exit.
+ (dump_section_as_bytes, process_notes_at): Likewise.
+ (get_build_id): Free enote.
+
2020-03-13 Kamil Rytarowski <n54@gmx.com>
* readelf.c (get_netbsd_elfcore_note_type): Add support for
2020-03-13 Kamil Rytarowski <n54@gmx.com>
* readelf.c (get_netbsd_elfcore_note_type): Add support for
{
warn (_("section '%s' has unsupported compress type: %d\n"),
printable_section_name (filedata, section), chdr.ch_type);
{
warn (_("section '%s' has unsupported compress type: %d\n"),
printable_section_name (filedata, section), chdr.ch_type);
}
uncompressed_size = chdr.ch_size;
start += compression_header_size;
}
uncompressed_size = chdr.ch_size;
start += compression_header_size;
{
error (_("Unable to decompress section %s\n"),
printable_section_name (filedata, section));
{
error (_("Unable to decompress section %s\n"),
printable_section_name (filedata, section));
putchar ('\n');
return TRUE;
putchar ('\n');
return TRUE;
+
+error_out:
+ free (real_start);
+ return FALSE;
{
warn (_("section '%s' has unsupported compress type: %d\n"),
printable_section_name (filedata, section), chdr.ch_type);
{
warn (_("section '%s' has unsupported compress type: %d\n"),
printable_section_name (filedata, section), chdr.ch_type);
}
uncompressed_size = chdr.ch_size;
start += compression_header_size;
}
uncompressed_size = chdr.ch_size;
start += compression_header_size;
error (_("Unable to decompress section %s\n"),
printable_section_name (filedata, section));
/* FIXME: Print the section anyway ? */
error (_("Unable to decompress section %s\n"),
printable_section_name (filedata, section));
/* FIXME: Print the section anyway ? */
if (relocate)
{
if (! apply_relocations (filedata, section, start, section_size, NULL, NULL))
if (relocate)
{
if (! apply_relocations (filedata, section, start, section_size, NULL, NULL))
putchar ('\n');
return TRUE;
putchar ('\n');
return TRUE;
+
+ error_out:
+ free (real_start);
+ return FALSE;
if (align < 4)
align = 4;
else if (align != 4 && align != 8)
if (align < 4)
align = 4;
else if (align != 4 && align != 8)
+ {
+ free (enote);
+ continue;
+ }
end = (char *) enote + length;
data_remaining = end - (char *) enote;
end = (char *) enote + length;
data_remaining = end - (char *) enote;
warn (_("\
malformed note encountered in section %s whilst scanning for build-id note\n"),
printable_section_name (filedata, shdr));
warn (_("\
malformed note encountered in section %s whilst scanning for build-id note\n"),
printable_section_name (filedata, shdr));
continue;
}
data_remaining -= min_notesz;
continue;
}
data_remaining -= min_notesz;
warn (_("\
malformed note encountered in section %s whilst scanning for build-id note\n"),
printable_section_name (filedata, shdr));
warn (_("\
malformed note encountered in section %s whilst scanning for build-id note\n"),
printable_section_name (filedata, shdr));
continue;
}
data_remaining -= min_notesz;
continue;
}
data_remaining -= min_notesz;
warn (_("\
malformed note encountered in section %s whilst scanning for build-id note\n"),
printable_section_name (filedata, shdr));
warn (_("\
malformed note encountered in section %s whilst scanning for build-id note\n"),
printable_section_name (filedata, shdr));
build_id = malloc (inote.descsz * 2 + 1);
if (build_id == NULL)
build_id = malloc (inote.descsz * 2 + 1);
if (build_id == NULL)
+ {
+ free (enote);
+ return NULL;
+ }
for (j = 0; j < inote.descsz; ++j)
sprintf (build_id + (j * 2), "%02x", inote.descdata[j] & 0xff);
build_id[inote.descsz * 2] = '\0';
for (j = 0; j < inote.descsz; ++j)
sprintf (build_id + (j * 2), "%02x", inote.descdata[j] & 0xff);
build_id[inote.descsz * 2] = '\0';
return (unsigned char *) build_id;
}
return (unsigned char *) build_id;
}
if (pnotes)
{
if (! apply_relocations (filedata, section, (unsigned char *) pnotes, length, NULL, NULL))
if (pnotes)
{
if (! apply_relocations (filedata, section, (unsigned char *) pnotes, length, NULL, NULL))
+ {
+ free (pnotes);
+ return FALSE;
+ }