mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-16 04:18:50 +00:00
Re: windres: don't exit so much on errors in read_coff_rsrc
oss-fuzz found that I missed some error paths in commit 9e68cae4fd.
This fix prevents reads of a NULL pointer in sort_resources.
* rescoff.c (read_coff_res_dir): Check return of recursive calls
and read_coff_data_entry calls. Pass failures up the call chain.
This commit is contained in:
@@ -308,6 +308,8 @@ read_coff_res_dir (windres_bfd *wrbfd, const bfd_byte *data,
|
|||||||
re->subdir = 1;
|
re->subdir = 1;
|
||||||
re->u.dir = read_coff_res_dir (wrbfd, flaginfo->data + rva, flaginfo,
|
re->u.dir = read_coff_res_dir (wrbfd, flaginfo->data + rva, flaginfo,
|
||||||
type, level + 1);
|
type, level + 1);
|
||||||
|
if (re->u.dir == NULL)
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -319,6 +321,8 @@ read_coff_res_dir (windres_bfd *wrbfd, const bfd_byte *data,
|
|||||||
re->subdir = 0;
|
re->subdir = 0;
|
||||||
re->u.res = read_coff_data_entry (wrbfd, flaginfo->data + rva,
|
re->u.res = read_coff_data_entry (wrbfd, flaginfo->data + rva,
|
||||||
flaginfo, type);
|
flaginfo, type);
|
||||||
|
if (re->u.res == NULL)
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
*pp = re;
|
*pp = re;
|
||||||
@@ -359,6 +363,8 @@ read_coff_res_dir (windres_bfd *wrbfd, const bfd_byte *data,
|
|||||||
re->subdir = 1;
|
re->subdir = 1;
|
||||||
re->u.dir = read_coff_res_dir (wrbfd, flaginfo->data + rva, flaginfo,
|
re->u.dir = read_coff_res_dir (wrbfd, flaginfo->data + rva, flaginfo,
|
||||||
type, level + 1);
|
type, level + 1);
|
||||||
|
if (re->u.dir == NULL)
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -370,6 +376,8 @@ read_coff_res_dir (windres_bfd *wrbfd, const bfd_byte *data,
|
|||||||
re->subdir = 0;
|
re->subdir = 0;
|
||||||
re->u.res = read_coff_data_entry (wrbfd, flaginfo->data + rva,
|
re->u.res = read_coff_data_entry (wrbfd, flaginfo->data + rva,
|
||||||
flaginfo, type);
|
flaginfo, type);
|
||||||
|
if (re->u.res == NULL)
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
*pp = re;
|
*pp = re;
|
||||||
|
|||||||
Reference in New Issue
Block a user