From owner-freebsd-bugs Thu Apr 3 10:20:08 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id KAA06834 for bugs-outgoing; Thu, 3 Apr 1997 10:20:08 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id KAA06815; Thu, 3 Apr 1997 10:20:05 -0800 (PST) Resent-Date: Thu, 3 Apr 1997 10:20:05 -0800 (PST) Resent-Message-Id: <199704031820.KAA06815@freefall.freebsd.org> Resent-From: gnats (GNATS Management) Resent-To: freebsd-bugs Resent-Reply-To: FreeBSD-gnats@freefall.FreeBSD.org, roberto@keltia.freenix.fr Received: from mexico.brainstorm.eu.org (mexico.brainstorm.fr [193.56.58.253]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id KAA06527 for ; Thu, 3 Apr 1997 10:15:30 -0800 (PST) Received: from brasil.brainstorm.eu.org (brasil.brainstorm.fr [193.56.58.33]) by mexico.brainstorm.eu.org (8.8.4/8.8.4) with ESMTP id UAA30426 for ; Thu, 3 Apr 1997 20:15:24 +0200 Received: (from uucp@localhost) by brasil.brainstorm.eu.org (8.8.4/8.6.12) with UUCP id UAA07081 for FreeBSD-gnats-submit@freebsd.org; Thu, 3 Apr 1997 20:15:01 +0200 Received: (from roberto@localhost) by keltia.freenix.fr (8.8.5/keltia-uucp-2.9) id UAA01773; Thu, 3 Apr 1997 20:06:14 +0200 (CEST) Message-Id: <199704031806.UAA01773@keltia.freenix.fr> Date: Thu, 3 Apr 1997 20:06:14 +0200 (CEST) From: Ollivier Robert Reply-To: roberto@keltia.freenix.fr To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: bin/3188: file(1) 3.22 doesn't work well with ELF binaries Sender: owner-bugs@freebsd.org X-Loop: FreeBSD.org Precedence: bulk >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: