Bug 109509 - File produces errors on ELF files with no section header
Summary: File produces errors on ELF files with no section header
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: file
Version: 9
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Radek Vokál
QA Contact: Mike McLean
URL: http://www.darkspiral.net/natasha/fil...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2003-11-08 21:11 UTC by Seth Randall
Modified: 2007-04-18 16:59 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2004-09-15 07:54:56 UTC
Embargoed:


Attachments (Terms of Use)
Check variable num and return if it's zero (748 bytes, patch)
2003-11-08 21:13 UTC, Seth Randall
no flags Details | Diff

Description Seth Randall 2003-11-08 21:11:20 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031018

Description of problem:
When running file on a ELF format file with no section header, file
produces a bogus warning. A sample session:

$ file epsxe
epsxe: ELF 32-bit LSB executable, Intel 80386, version 1 (Linux),
statically linkedfile: corrupted section header size.

The code responsible for the corrupted section header size. is added
by the file-3.39-cksize.patch patch. In the functions doshn,
dophn_exec, and dophn_core, the following checks are made:

doshn:

        if (size != sh_size)
            error("corrupted section header size.\n");
    

dophn_exec:
dophn_core:

        if (size != ph_size)
            error("corrupted program header size.\n");
    

sh_size and ph_size are the sizes of the ELF headers and size is the
size of the header being looked up.

But, size can be zero if there is no section or program header. If a
program has now section header, a incorrect error is returned. See ELF
Header

A simple fix is to check if num or size are zero and return if they are.

A patch is attached to fix the problem.

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

How reproducible:
Always

Steps to Reproduce:
1. Run upx on a ELF executable
2. Run file on the resulting file
3.
    

Actual Results:  I got a line saying
epsxe: ELF 32-bit LSB executable, Intel 80386, version 1 (Linux),
statically linkedfile: corrupted section header size.

Expected Results:  It should only say
epsxe: ELF 32-bit LSB executable, Intel 80386, version 1 (Linux),
statically linked

Additional info:

If file doesn't like the executable, then its use in brp-strip
prevents the creation of RPMS

Comment 1 Seth Randall 2003-11-08 21:13:15 UTC
Created attachment 95833 [details]
Check variable num and return if it's zero

Comment 2 Radek Vokál 2004-09-15 07:54:56 UTC
Fixed in file-4.10-1. File reports "no section header"


Note You need to log in before you can comment on or make changes to this bug.