Bug 1522732

Summary: readelf exit status is 0 for empty zero-length file
Product: [Fedora] Fedora Reporter: Michael Stahl <mstahl>
Component: binutilsAssignee: Nick Clifton <nickc>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 27CC: aoliva, dvlasenk, jakub, nickc
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: binutils-2.29-8.fc27 binutils-2.29-13.fc27 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-03-13 23:17:49 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Michael Stahl 2017-12-06 10:33:49 UTC
Description of problem:

readelf exit status is 0 for empty zero-length file

Version-Release number of selected component (if applicable):

binutils-2.29-6.fc27.x86_64

How reproducible:

always

Steps to Reproduce:

from Fedora 26 to Fedora 27, the readelf exit status changed from 1
to 0 when running "readelf -d" on an empty file:

old:

> touch /tmp/foo
> readelf -d /tmp/foo 
readelf: /tmp/foo: Error: Failed to read file's magic number
> echo $?
1
> readelf --version
GNU readelf version 2.27-28.fc26
Copyright (C) 2016 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.

new:

> touch /tmp/foo
> readelf -d /tmp/foo
readelf: /tmp/foo: Error: Failed to read file's magic number
> echo $?
0
> readelf --version
GNU readelf version 2.29-6.fc27
Copyright (C) 2017 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.


but readelf still prints an error - so i think it should not exit with 0.

Comment 1 Nick Clifton 2017-12-06 12:33:57 UTC
Hi Michael,

  Thanks for reporting this bug.  The problem was an error in a Fedora local
  patch that "improves" readelf so that it reports the filename in error
  messages.  (Which only really makes a difference when readelf is run on
  multiple files at the same time).

  I have checked in a patch to fix the problem, so please try the new 
  binutils-2.29-8.fc27 rpm.  (Once it finished building...)

Cheers
  Nick

Comment 2 Michael Stahl 2017-12-07 19:56:44 UTC
okay, installed rpm from koji, my script runs without spurious errors now.

https://koji.fedoraproject.org/koji/buildinfo?buildID=1007764

Comment 3 Fedora Update System 2018-03-08 14:20:59 UTC
binutils-2.29-13.fc27 has been submitted as an update to Fedora 27. https://bodhi.fedoraproject.org/updates/FEDORA-2018-1e994c659e

Comment 4 Fedora Update System 2018-03-08 16:24:22 UTC
binutils-2.29-13.fc27 has been pushed to the Fedora 27 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2018-1e994c659e

Comment 5 Fedora Update System 2018-03-13 23:17:49 UTC
binutils-2.29-13.fc27 has been pushed to the Fedora 27 stable repository. If problems still persist, please make note of it in this bug report.