From nobody@FreeBSD.org  Thu Feb 10 23:36:11 2011
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id D38D41065679
	for <freebsd-gnats-submit@FreeBSD.org>; 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 <freebsd-gnats-submit@FreeBSD.org>; 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 <freebsd-gnats-submit@FreeBSD.org>; 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 <justinbb@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: hexdump: length of final run incorrectly reported
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         154664
>Category:       bin
>Synopsis:       hexdump: length of final run incorrectly reported
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Feb 10 23:40:09 UTC 2011
>Closed-Date:    Fri Feb 11 02:52:37 UTC 2011
>Last-Modified:  Fri Feb 11 02:52:37 UTC 2011
>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:

From: Justin Bur <justinbb@gmail.com>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/154664: hexdump: length of final run incorrectly reported
Date: Thu, 10 Feb 2011 20:28:19 -0500

 I fear it resembles bin/118723 rather a lot. My apologies for the duplicate.
State-Changed-From-To: open->closed 
State-Changed-By: linimon 
State-Changed-When: Fri Feb 11 02:51:51 UTC 2011 
State-Changed-Why:  
See bin/118723. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=154664 
>Unformatted:
