Date: Thu, 3 Apr 1997 20:06:14 +0200 (CEST) From: Ollivier Robert <roberto@keltia.freenix.fr> To: FreeBSD-gnats-submit@freebsd.org Subject: bin/3188: file(1) 3.22 doesn't work well with ELF binaries Message-ID: <199704031806.UAA01773@keltia.freenix.fr> Resent-Message-ID: <199704031820.KAA06815@freefall.freebsd.org>
index | next in thread | raw e-mail
>Number: 3188
>Category: bin
>Synopsis: Reading the ELF header leads to an error
>Confidential: no
>Severity: serious
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Thu Apr 3 10:20:04 PST 1997
>Last-Modified:
>Originator: Ollivier Robert
>Organization:
Usenet Canal Historique
>Release: FreeBSD 3.0-CURRENT i386
>Environment:
CURRENT from March, 23th.
285 [19:58] roberto@keltia:/tmp/file> file -v
file-3.22
>Description:
The new file(1) is trying to directly read ELF headers to show
information. It seems that the following section of code is failing:
static void
doshn(fd, off, num, size, buf)
int fd;
off_t off;
int num;
size_t size;
char *buf;
{
/*
* This works for both 32-bit and 64-bit ELF formats,
* because it looks only at the "sh_type" field, which is
* always 32 bits, and is preceded only by the "sh_name"
* field which is also always 32 bits, and because it uses
* the shdr size from the ELF header rather than using
* the size of an "Elf32_Shdr".
*/
Elf32_Shdr *sh = (Elf32_Shdr *) buf;
if (lseek(fd, off, SEEK_SET) == -1)
error("lseek failed (%s).\n", strerror(errno));
for ( ; num; num--) {
if (read(fd, buf, size) == -1)
error("read failed (%s).\n", strerror(errno));
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>How-To-Repeat:
Trying to identify some ELF binaries (both Linux and FreeBSD ones)
leads to the following error message:
Linux:
284 [19:58] roberto@keltia:/tmp/file> file acroread
acroread: ELF 32-bit LSB executable, Intel 80386, version 1file: read failed (Invalid argument).
FreeBSD:
286 [19:59] roberto@keltia:/tmp/file> file ../foo
../foo: ELF 32-bit LSB executable, Intel 80386, version 1file: read failed (Invalid argument).
The old method -- using /etc/magic ELF section -- worked right.
>Fix:
Unknown.
>Audit-Trail:
>Unformatted:
home |
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199704031806.UAA01773>
