Date: Sat, 15 Dec 2007 18:09:53 GMT From: Mark Adler <madler@alumni.caltech.edu> To: freebsd-gnats-submit@FreeBSD.org Subject: misc/118723: [patch] od/hexdump truncates last partial repeat line Message-ID: <200712151809.lBFI9r87031927@www.freebsd.org> Resent-Message-ID: <200712151820.lBFIK1Zt024579@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 118723
>Category: misc
>Synopsis: [patch] od/hexdump truncates last partial repeat line
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Sat Dec 15 18:20:01 UTC 2007
>Closed-Date:
>Last-Modified:
>Originator: Mark Adler
>Release: hexdump 1.19 (same problem with 1.22)
>Organization:
>Environment:
Darwin gromit 8.11.0 Darwin Kernel Version 8.11.0: Wed Oct 10 18:26:00 PDT 2007; root:xnu-792.24.17~1/RELEASE_PPC Power Macintosh powerpc
>Description:
od and hexdump truncates the last line of the dump when that line partially repeats the previous line.
>How-To-Repeat:
Create this 40-byte file (including five newline characters):
abcdefg
0123456
abcdefg
0123456
abcdefg
(Just the first three lines, 24 bytes, shows the same problem, but I included five lines to make the structure more evident.)
od on that file incorrectly gives:
0000000 060542 061544 062546 063412 030061 031063 032065 033012
*
0000040
which leaves off the last line "abcdefg\n", and incorrectly shows the final address as 40 octal (32 decimal).
Similarly, hexdump gives the following with the same issues:
0000000 6162 6364 6566 670a 3031 3233 3435 360a
*
0000020
With the patch below, od then correctly displays:
0000000 060542 061544 062546 063412 030061 031063 032065 033012
*
0000040 060542 061544 062546 063412
0000050
and hexdump then correctly displays:
0000000 6162 6364 6566 670a 3031 3233 3435 360a
*
0000020 6162 6364 6566 670a
0000028
>Fix:
Patch relative to latest version (1.22):
*** display-122.c Tue Aug 3 19:47:32 2004
--- display.c Sat Dec 15 09:51:26 2007
***************
*** 263,279 ****
errx(1, "cannot skip past end of input");
if (need == blocksize)
return((u_char *)NULL);
- /*
- * XXX bcmp() is not quite right in the presence
- * of multibyte characters.
- */
- if (vflag != ALL &&
- valid_save &&
- bcmp(curp, savp, nread) == 0) {
- if (vflag != DUP)
- (void)printf("*\n");
- return((u_char *)NULL);
- }
bzero((char *)curp + nread, need);
eaddress = address + nread;
return(curp);
--- 263,268 ----
>Release-Note:
>Audit-Trail:
>Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200712151809.lBFI9r87031927>
