NetBSD Problem Report #9195
Received: (qmail 25023 invoked from network); 15 Jan 2000 12:20:20 -0000
Message-Id: <200001151221.VAA22011@serein.jaist.ac.jp>
Date: Sat, 15 Jan 2000 21:21:10 +0900 (JST)
From: akr@jaist.ac.jp
Reply-To: akr@jaist.ac.jp
To: gnats-bugs@gnats.netbsd.org
Subject: od prints only `*' for short file only containing NULs.
X-Send-Pr-Version: 3.95
>Number: 9195
>Category: bin
>Synopsis: od prints only `*' for short file only containing NULs.
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: bin-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Jan 15 04:20:58 +0000 2000
>Closed-Date: Thu Feb 15 18:16:31 +0000 2001
>Last-Modified: Thu Feb 15 18:16:31 +0000 2001
>Originator: Tanaka Akira
>Release: 1.4.1
>Organization:
>Environment:
System: NetBSD serein 1.4.1 NetBSD 1.4.1 (AKR) #3: Sun Sep 19 11:43:39 JST 1999 akr@localhost:/usr/src/sys/arch/i386/compile/AKR i386
>Description:
When an input of od is short sequence of NULs, od print only `*'.
>How-To-Repeat:
$ perl -e 'print "\0"' | od
*
$ perl -e 'print "\0" x 15' | od
*
$
>Fix:
>Release-Note:
>Audit-Trail:
From: Aymeric Vincent <vincent@crans.ens-cachan.fr>
To: akr@jaist.ac.jp
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: bin/9195: od prints only `*' for short file only containing NULs.
Date: 16 Jan 2000 00:54:09 +0100
> When an input of od is short sequence of NULs, od print only `*'.
I don't know what the correct semantics is, but I would too prefer not
to get a star here, but the right number of zeroes.
Here is a patch that does this.
It just keeps track of whether savp is `valid' or not. Please note
that there is another place where savp is compared to curp, but this
compare doesn't need to be protected by a !invsavp since it can't
happen at a time where savp is invalid (because of the vflag == FIRST
right before).
HTH,
Aymeric
===================================================================
RCS file: /cvsroot/basesrc/usr.bin/hexdump/display.c,v
retrieving revision 1.8
diff -u -r1.8 display.c
--- display.c 1999/11/09 15:06:36 1.8
+++ display.c 2000/01/15 23:46:01
@@ -234,6 +234,7 @@
get()
{
static int ateof = 1;
+ static int invsavp = 1;
static u_char *curp, *savp;
int n;
int need, nread;
@@ -247,6 +248,7 @@
curp = savp;
savp = tmpp;
address += blocksize;
+ invsavp = 0;
}
for (need = blocksize, nread = 0;;) {
/*
@@ -257,7 +259,8 @@
if (!length || (ateof && !next(NULL))) {
if (need == blocksize)
return(NULL);
- if (vflag != ALL && !memcmp(curp, savp, nread)) {
+ if (vflag != ALL && !invsavp &&
+ !memcmp(curp, savp, nread)) {
if (vflag != DUP)
(void)printf("*\n");
return(NULL);
From: Tanaka Akira <akr@jaist.ac.jp>
To: Aymeric Vincent <vincent@crans.ens-cachan.fr>
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: bin/9195: od prints only `*' for short file only containing NULs.
Date: 19 Jan 2000 05:42:58 +0900
In article <x7zou6howt.fsf@ungnu.meka7.de>,
Aymeric Vincent <vincent@crans.ens-cachan.fr> writes:
> I don't know what the correct semantics is, but I would too prefer not
> to get a star here, but the right number of zeroes.
>
> Here is a patch that does this.
Your patch fixes the problem with "\0" x 1 to 15. Thanks.
But it has the problem with "\0" x 17 or longer.
% perl -e 'print "\0" x 17' | ./od -b
0000000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000
*
0000020
% perl -e 'print "\0" x 31' | ./od -b
0000000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000
*
0000020
%
I think od should produce results which can be desitinguished.
At least, od on Solaris 7 and GNU textutils does.
Solaris 7:
% perl -e 'print "\0" x 17' | od -b
0000000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000
*
0000021
% perl -e 'print "\0" x 31' | od -b
0000000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000
*
0000037
%
GNU textutils:
% perl -e 'print "\0" x 17' | /pkg/all/bin/od -b
0000000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000
0000020 000
0000021
% perl -e 'print "\0" x 31' | /pkg/all/bin/od -b
0000000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000
0000020 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000
0000037
%
--
Tanaka Akira
From: Aymeric Vincent <Aymeric.Vincent@crans.ens-cachan.fr>
To: Tanaka Akira <akr@jaist.ac.jp>
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: bin/9195: od prints only `*' for short file only containing NULs.
Date: 18 Jan 2000 22:11:15 +0100
Tanaka Akira <akr@jaist.ac.jp> writes:
> Your patch fixes the problem with "\0" x 1 to 15. Thanks.
> But it has the problem with "\0" x 17 or longer.
Ooops... Sorry, I had misunderstood the problem... Here is a simpler
yet better fix. However, you'll have to apply it to a fresh display.c
file from the repository (i.e. unapply the previous patch).
Here are a few tests like yours that I believe to be relevant (dd's
stderr removed for readability, I don't have perl ;)
stack@ungnu[52]% dd if=/dev/zero count=1 bs=5 | od -b
0000000 000 000 000 000 000
0000005
stack@ungnu[53]% dd if=/dev/zero count=1 bs=16 | od -b
0000000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000
0000020
stack@ungnu[54]% dd if=/dev/zero count=1 bs=17 | od -b
0000000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000
0000020 000
0000021
stack@ungnu[55]% dd if=/dev/zero count=1 bs=32 | od -b
0000000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000
*
0000040
stack@ungnu[56]% dd if=/dev/zero count=1 bs=31 | od -b
0000000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000
0000020 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000
0000037
stack@ungnu[57]%
regards,
Aymeric
Index: display.c
===================================================================
RCS file: /cvsroot/basesrc/usr.bin/hexdump/display.c,v
retrieving revision 1.8
diff -u -r1.8 display.c
--- display.c 1999/11/09 15:06:36 1.8
+++ display.c 2000/01/18 21:03:19
@@ -257,7 +257,8 @@
if (!length || (ateof && !next(NULL))) {
if (need == blocksize)
return(NULL);
- if (vflag != ALL && !memcmp(curp, savp, nread)) {
+ if (vflag != ALL && nread == blocksize &&
+ !memcmp(curp, savp, nread)) {
if (vflag != DUP)
(void)printf("*\n");
return(NULL);
From: Andrew Brown <atatat@atatdot.net>
To: akr@jaist.ac.jp
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: bin/9195: od prints only `*' for short file only containing NULs.
Date: Tue, 18 Jan 2000 19:08:01 -0500
>>Number: 9195
>>Category: bin
>>Synopsis: od prints only `*' for short file only containing NULs.
>...
>>How-To-Repeat:
>
>
>$ perl -e 'print "\0"' | od
>*
>$ perl -e 'print "\0" x 15' | od
>*
>$
>
>>Fix:
this patch seems to fix it. for me at least. then again, i'm of the
opinion that a a partial line should *not* match the previous line no
matter what. i think the bug is actually a manifestation of the fact
that the previous line doesn't exist, so comparing some zeroes to
something which was never used is always going to lose. if you can
follow that. :)
*** display.c-orig Tue Nov 9 10:06:36 1999
--- display.c Tue Jan 18 19:01:54 2000
***************
*** 257,263 ****
if (!length || (ateof && !next(NULL))) {
if (need == blocksize)
return(NULL);
! if (vflag != ALL && !memcmp(curp, savp, nread)) {
if (vflag != DUP)
(void)printf("*\n");
return(NULL);
--- 257,263 ----
if (!length || (ateof && !next(NULL))) {
if (need == blocksize)
return(NULL);
! if (!need && vflag != ALL && !memcmp(curp, savp, nread)) {
if (vflag != DUP)
(void)printf("*\n");
return(NULL);
--
|-----< "CODE WARRIOR" >-----|
codewarrior@daemon.org * "ah! i see you have the internet
twofsonet@graffiti.com (Andrew Brown) that goes *ping*!"
andrew@crossbar.com * "information is power -- share the wealth."
State-Changed-From-To: open->closed
State-Changed-By: christos
State-Changed-When: Thu Feb 15 13:12:08 EST 2001
State-Changed-Why:
Applied Andrew's fix
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.