From owner-freebsd-bugs@FreeBSD.ORG Thu Feb 10 23:40:10 2011 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 80A87106564A for ; Thu, 10 Feb 2011 23:40:10 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 44B298FC1C for ; Thu, 10 Feb 2011 23:40:10 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id p1ANeAlV072161 for ; Thu, 10 Feb 2011 23:40:10 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id p1ANeAQs072160; Thu, 10 Feb 2011 23:40:10 GMT (envelope-from gnats) Resent-Date: Thu, 10 Feb 2011 23:40:10 GMT Resent-Message-Id: <201102102340.p1ANeAQs072160@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Justin Bur Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D38D41065679 for ; Thu, 10 Feb 2011 23:36:11 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id C3A838FC17 for ; Thu, 10 Feb 2011 23:36:11 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p1ANaBYJ058797 for ; Thu, 10 Feb 2011 23:36:11 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.4/8.14.4/Submit) id p1ANaBnL058796; Thu, 10 Feb 2011 23:36:11 GMT (envelope-from nobody) Message-Id: <201102102336.p1ANaBnL058796@red.freebsd.org> Date: Thu, 10 Feb 2011 23:36:11 GMT From: Justin Bur To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: bin/154664: hexdump: length of final run incorrectly reported X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Feb 2011 23:40:10 -0000 >Number: 154664 >Category: bin >Synopsis: hexdump: length of final run incorrectly reported >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Feb 10 23:40:09 UTC 2011 >Closed-Date: >Last-Modified: >Originator: Justin Bur >Release: Mac OS X 10.6.6 >Organization: >Environment: Darwin incandescence 10.6.0 Darwin Kernel Version 10.6.0: Wed Nov 10 18:13:17 PST 2010; root:xnu-1504.9.26~3/RELEASE_I386 i386 >Description: hexdump (od) does not report correctly the length of a long run of identical characters at the end of a file. Instead, the final byte count reported is that of the last full block (of 16 characters with the default options). (This situation occurs rarely with Unix text files, since they almost always end with a single newline.) >How-To-Repeat: Create a file containing the letter 'a' 17 times, with no final newline. Run hexdump with no options. % echo -n 'aaaaaaaaaaaaaaaaa' > test % wc test 0 1 17 test % hexdump test 0000000 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 * 0000010 The final byte count 0x10 should be 0x11 (cf. output from wc, which indicates length 17). >Fix: File head/usr.bin/hexdump/display.c, function get(), near line 271 (as of r216370) in the if-clause that begins if (vflag != ALL && valid_save && bcmp(curp, savp, nread) == 0) the variable "eaddress" should be set before returning. The same line that occurs just past the end of the if seems to work correctly here as well: eaddress = address + nread; >Release-Note: >Audit-Trail: >Unformatted: