From owner-freebsd-bugs Thu Sep 20 7:30:14 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 79C5F37B413 for ; Thu, 20 Sep 2001 07:30:03 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.4/8.11.4) id f8KEU3q32244; Thu, 20 Sep 2001 07:30:03 -0700 (PDT) (envelope-from gnats) Received: from lion.com.ua (lion.com.ua [213.133.161.130]) by hub.freebsd.org (Postfix) with ESMTP id 7E68E37B409 for ; Thu, 20 Sep 2001 07:27:57 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by lion.com.ua (8.11.4/8.11.4) with ESMTP id f8KERtF01197 for ; Thu, 20 Sep 2001 17:27:55 +0300 (EEST) (envelope-from sa@simon.org.ua) Message-Id: <20010920172441.V1185-100000@lion.com.ua> Date: Thu, 20 Sep 2001 17:27:54 +0300 (EEST) From: Andrey Simonenko To: Subject: bin/30685: Patch for usr.bin/hexdump Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >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