Subject: bin/14798: hexdump shows wrong file length when input ends with incomplete duplicate line
To: None <gnats-bugs@gnats.netbsd.org>
From: None <dpeschel@eskimo.com>
List: netbsd-bugs
Date: 11/30/2001 16:25:23
>Number:         14798
>Category:       bin
>Synopsis:       hexdump shows wrong file length when input ends with incomplete duplicate line
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Nov 30 16:26:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Derek Peschel
>Release:        1.5
>Organization:
>Environment:
NetBSD  1.5 NetBSD 1.5 (DHP) #0: Fri Sep 21 07:55:18 PDT 2001     dpeschel@localhost.localdomain:/usr/src/sys/arch/macppc/compile/DHP macppc
>Description:
It doesn't make any difference whether hexdump is called as "hexdump" or "od".

When using the -b or -c switches, one line of output is sixteen bytes.  So by "line" I mean a group of sixteen bytes.

If the input ends with duplicate lines, and the last line is less than sixteen bytes, hexdump won't use the last line in calculating the file length.  The real od (on SunOS 4.1.4) prints the correct length.

But hexdump will print the correct length if:

	the input ends with duplicate lines, and the last line is sixteen bytes,

	the input contains duplicate lines but ends with a non-duplicate line,

	or the -v switch is given.
>How-To-Repeat:
Put "abcdefghijklmnopabcdefghijklmno" (without the quote marks and without a newline at the end) in a file called "od.in".  Type "od -cv od.in".  The last line shows the correct length of 0000037.  Then type "od -c od.in".  The last line incorrectly says 0000020.

Put "abcdefghijklmnopabcdefghijklmnop" (without the quote marks and without a newline at the end) in a file called "od.in2".  Type "od -cv od.in2".  Then type "od -c od.in2".  In both cases the last line correctly says 0000040.

Put "abcdefghijklmnopabcdefghijklmnopaaaaa" (without the quote marks and without a newline at the end) in a file called "od.in3".  Type "od -cv od.in3".  Then type "od -c od.in3".  In both cases the last line correctly says 0000045.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted: