Date: Thu, 20 Sep 2001 17:27:54 +0300 (EEST) From: Andrey Simonenko <simon@simon.org.ua> To: <FreeBSD-gnats-submit@freebsd.org> Subject: bin/30685: Patch for usr.bin/hexdump Message-ID: <20010920172441.V1185-100000@lion.com.ua>
next in thread | raw e-mail | index | archive | help
>Number: 30685
>Category: bin
>Synopsis: Patch for usr.bin/hexdump
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Thu Sep 20 07:30:03 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: Andrey Simonenko
>Release: FreeBSD 4.4-RC i386
>Organization:
>Environment:
FreeBSD 4.4-RC i386
>Description:
hexdump(8) expects that an argument for -e option is always surrounded by
double quote (" ") marks. And following calls generate core-dumps:
$ hexdump -e "" some-file
$ hexdump -e "\"%c\"" -e " " some-file
hexdump(8) shouldn't generate core-dumps in reaction on -e "" option,
instead it should skip this format string as empty.
Following patch fixes described above problem with hexdump(8).
>How-To-Repeat:
$ hexdump -e "" /COPYRIGHT
$ hexdump -e "\"%c\"" -e " " /COPYRIGHT
I checked original hexdump and patched hexdump with different format
strings in -e option, and didn't find any differences in outputs.
>Fix:
diff -ru /usr/src/usr.bin/hexdump/parse.c hexdump/parse.c
--- /usr/src/usr.bin/hexdump/parse.c Sat Aug 28 04:02:03 1999
+++ hexdump/parse.c Thu Sep 20 17:01:09 2001
@@ -413,7 +413,7 @@
* If, rep count is greater than 1, no trailing whitespace
* gets output from the last iteration of the format unit.
*/
- for (fu = fs->nextfu;; fu = fu->nextfu) {
+ for (fu = fs->nextfu; fu != NULL; fu = fu->nextfu) {
if (!fu->nextfu && fs->bcnt < blocksize &&
!(fu->flags&F_SETREP) && fu->bcnt)
fu->reps += (blocksize - fs->bcnt) / fu->bcnt;
@@ -426,8 +426,6 @@
if (p2)
pr->nospace = p2;
}
- if (!fu->nextfu)
- break;
}
#ifdef DEBUG
for (fu = fs->nextfu; fu; fu = fu->nextfu) {
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010920172441.V1185-100000>
