ctf segfaults

PR 30228
	PR 30229
	* ctf-open.c (ctf_bufopen_internal): Check for NULL cts_data.
	* ctf-archive.c (ctf_arc_bufpreamble, ctf_arc_bufopen): Likewise.
This commit is contained in:
Alan Modra
2023-03-17 21:09:31 +10:30
parent 52435e5ff6
commit 027333da75
2 changed files with 8 additions and 5 deletions

View File

@@ -402,8 +402,9 @@ ctf_arc_symsect_endianness (ctf_archive_t *arc, int little_endian)
const ctf_preamble_t *
ctf_arc_bufpreamble (const ctf_sect_t *ctfsect)
{
if (ctfsect->cts_size > sizeof (uint64_t) &&
(le64toh ((*(uint64_t *) ctfsect->cts_data)) == CTFA_MAGIC))
if (ctfsect->cts_data != NULL
&& ctfsect->cts_size > sizeof (uint64_t)
&& (le64toh ((*(uint64_t *) ctfsect->cts_data)) == CTFA_MAGIC))
{
struct ctf_archive *arc = (struct ctf_archive *) ctfsect->cts_data;
return (const ctf_preamble_t *) ((char *) arc + le64toh (arc->ctfa_ctfs)
@@ -424,8 +425,9 @@ ctf_arc_bufopen (const ctf_sect_t *ctfsect, const ctf_sect_t *symsect,
int is_archive;
ctf_dict_t *fp = NULL;
if (ctfsect->cts_size > sizeof (uint64_t) &&
(le64toh ((*(uint64_t *) ctfsect->cts_data)) == CTFA_MAGIC))
if (ctfsect->cts_data != NULL
&& ctfsect->cts_size > sizeof (uint64_t)
&& (le64toh ((*(uint64_t *) ctfsect->cts_data)) == CTFA_MAGIC))
{
/* The archive is mmappable, so this operation is trivial.