mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-26 17:18:55 +00:00
windres: don't exit so much on errors in read_coff_rsrc
windres code has the habit of exiting on any error. That's not so bad, but it does make oss-fuzz ineffective when testing windres. Fix many places that print errors and exit to instead print the error and pass status up the call chain. In the process of doing this, I noticed write_res_file was calling bfd_close without checking return status. Fixing that resulted in lots of testsuite failures. The problem was a lack of bfd_set_format in windres_open_as_binary, which leaves the output file as bfd_unknown format. As it happens this doesn't make any difference in writing the output binary file, except for the bfd_close return status.
This commit is contained in:
@@ -1938,7 +1938,7 @@ indent (FILE *e, int c)
|
||||
refer to that file, we use the user-data model for that to express it binary
|
||||
without the need to store it somewhere externally. */
|
||||
|
||||
void
|
||||
bool
|
||||
write_rc_file (const char *filename, const rc_res_directory *res_dir)
|
||||
{
|
||||
FILE *e;
|
||||
@@ -1950,12 +1950,17 @@ write_rc_file (const char *filename, const rc_res_directory *res_dir)
|
||||
{
|
||||
e = fopen (filename, FOPEN_WT);
|
||||
if (e == NULL)
|
||||
fatal (_("can't open `%s' for output: %s"), filename, strerror (errno));
|
||||
{
|
||||
non_fatal (_("can't open `%s' for output: %s"),
|
||||
filename, strerror (errno));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
language = (rc_uint_type) ((bfd_signed_vma) -1);
|
||||
write_rc_directory (e, res_dir, (const rc_res_id *) NULL,
|
||||
(const rc_res_id *) NULL, &language, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Write out a directory. E is the file to write to. RD is the
|
||||
|
||||
Reference in New Issue
Block a user