Fix bug running readelf on an empty file. (#1903448)

Fix bug running readelf on a file that cannot be read.  (#1913589)
This commit is contained in:
Nick Clifton 2021-01-08 17:47:26 +00:00
commit e4e1fcf172
2 changed files with 27 additions and 1 deletions

View file

@ -121,3 +121,25 @@
free (ba_cache.strtab);
ba_cache.strtab = NULL;
--- binutils.orig/binutils/readelf.c 2021-01-07 12:59:35.802994842 +0000
+++ binutils-2.35.1/binutils/readelf.c 2021-01-07 13:02:36.591754005 +0000
@@ -20818,7 +20818,8 @@ process_file (char * file_name)
done:
if (filedata)
{
- fclose (filedata->handle);
+ if (filedata->handle != NULL)
+ fclose (filedata->handle);
free (filedata->section_headers);
free (filedata->program_headers);
free (filedata->string_table);
--- binutils.orig/binutils/readelf.c 2021-01-08 17:01:23.573093204 +0000
+++ binutils-2.35.1/binutils/readelf.c 2021-01-08 17:02:23.095677242 +0000
@@ -20787,7 +20787,6 @@ process_file (char * file_name)
if (fread (armag, SARMAG, 1, filedata->handle) != 1)
{
error (_("Failed to read file's magic number\n"));
- fclose (filedata->handle);
goto done;
}

View file

@ -2,7 +2,7 @@
Summary: A GNU collection of binary utilities
Name: %{?cross}binutils%{?_with_debug:-debug}
Version: 2.35
Release: 15%{?dist}
Release: 16%{?dist}
License: GPLv3+
URL: https://sourceware.org/binutils
@ -823,6 +823,10 @@ exit 0
#----------------------------------------------------------------------------
%changelog
* Fri Jan 08 2021 Nick Clifton <nickc@redhat.com> - 2.35-16
- Fix bug running readelf on an empty file. (#1903448)
- Fix bug running readelf on a file that cannot be read. (#1913589)
* Fri Nov 27 2020 Mark Wielaard <mjw@fedoraproject.org> - 2.35-15
- Add DWARF5 fixes from 2_35-branch.