Fix the assembler's check that the output file is not also one of the input files.

Resolves: #1660279
This commit is contained in:
Nick Clifton 2019-01-30 11:51:57 +00:00
parent 20b09dd8e9
commit cfd1d13e29
2 changed files with 46 additions and 1 deletions

View File

@ -0,0 +1,37 @@
--- binutils.orig/gas/as.c 2019-01-30 11:02:04.055574300 +0000
+++ binutils-2.31.1/gas/as.c 2019-01-30 11:03:12.212050935 +0000
@@ -1254,14 +1254,27 @@ main (int argc, char ** argv)
{
struct stat sib;
- if (stat (argv[i], &sib) == 0)
+ /* Check that the input file and output file are different. */
+ if (stat (argv[i], &sib) == 0
+ && sib.st_ino == sob.st_ino
+ /* POSIX emulating systems may support stat() but if the
+ underlying file system does not support a file serial number
+ of some kind then they will return 0 for the inode. So
+ two files with an inode of 0 may not actually be the same.
+ On real POSIX systems no ordinary file will ever have an
+ inode of 0. */
+ && sib.st_ino != 0
+ /* Different files may have the same inode number if they
+ reside on different devices, so check the st_dev field as
+ well. */
+ && sib.st_dev == sob.st_dev)
{
- if (sib.st_ino == sob.st_ino && sib.st_ino != 0)
- {
- /* Don't let as_fatal remove the output file! */
- out_file_name = NULL;
- as_fatal (_("The input and output files must be distinct"));
- }
+ const char *saved_out_file_name = out_file_name;
+
+ /* Don't let as_fatal remove the output file! */
+ out_file_name = NULL;
+ as_fatal (_("The input '%s' and output '%s' files are the same"),
+ argv[i], saved_out_file_name);
}
}
}

View File

@ -69,7 +69,7 @@
Summary: A GNU collection of binary utilities
Name: %{?cross}binutils%{?_with_debug:-debug}
Version: 2.31.1
Release: 16%{?dist}
Release: 17%{?dist}
License: GPLv3+
URL: https://sourceware.org/binutils
@ -195,6 +195,10 @@ Patch18: binutils-gold-discard-version-info.patch
# Lifetime: Fixed in 2.32
Patch19: binutils-CVE-2018-20002.patch
# Purpose: Fix assembler check for an output file matching an input file.
# Lifetime: Fixed in 2.32
Patch20: binutils-gas-input-matches-output.patch
#----------------------------------------------------------------------------
Provides: bundled(libiberty)
@ -337,6 +341,7 @@ using libelf instead of BFD.
%patch17 -p1
%patch18 -p1
%patch19 -p1
%patch20 -p1
# We cannot run autotools as there is an exact requirement of autoconf-2.59.
@ -744,6 +749,9 @@ exit 0
#----------------------------------------------------------------------------
%changelog
* Wed Jan 30 2019 Nick Clifton <nickc@redhat.com> - 2.31.1-17
- Fix the assembler's check that the output file is not also one of the input files. (#1660279)
* Thu Jan 03 2019 Nick Clifton <nickc@redhat.com> - 2.31.1-16
- Fix a memory leak reading minisymbols. (#1661535)