From owner-freebsd-questions@FreeBSD.ORG Fri Jul 2 15:25:24 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3BEBF1065686 for ; Fri, 2 Jul 2010 15:25:24 +0000 (UTC) (envelope-from freebsd-questions-local@be-well.ilk.org) Received: from mail6.sea5.speakeasy.net (mail6.sea5.speakeasy.net [69.17.117.50]) by mx1.freebsd.org (Postfix) with ESMTP id 183C78FC19 for ; Fri, 2 Jul 2010 15:25:23 +0000 (UTC) Received: (qmail 32012 invoked from network); 2 Jul 2010 15:25:22 -0000 Received: from dsl092-078-145.bos1.dsl.speakeasy.net (HELO be-well.ilk.org) ([66.92.78.145]) (envelope-sender ) by mail6.sea5.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 2 Jul 2010 15:25:22 -0000 Received: by be-well.ilk.org (Postfix, from userid 1147) id D8CC95084D; Fri, 2 Jul 2010 11:25:20 -0400 (EDT) From: Lowell Gilbert To: freebsd-questions@freebsd.org References: <4C2DF07F.1020509@tundraware.com> Date: Fri, 02 Jul 2010 11:25:20 -0400 In-Reply-To: <4C2DF07F.1020509@tundraware.com> (Tim Daneliuk's message of "Fri, 02 Jul 2010 08:58:23 -0500") Message-ID: <44630xq527.fsf@be-well.ilk.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: 'file' Command Giving False Positives X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Jul 2010 15:25:24 -0000 Tim Daneliuk writes: > I have a data file with the content: > > LZasdadqjwjqwjqwjeqwe > > > 'file' (incorrectly) reports this as an MS-DOS executable. Why is it incorrect? "LZ" as the first two bytes in a file is (unless my memory is badly mistaken) exactly what the old command.com looked for as the flag of an executable. > Does anyone happen to know the proper changes to 'magic' that would > fix this? That would be tricky, given that MS-DOS *would*, in fact, think this file was a valid executable. I don't think the syntax of "magic" is powerful enough to distinguish this from a "real" executable. You might be able to do it by adding file(1) support for looking for invalid opcodes, but that would get hairy very quickly...