From owner-freebsd-bugs Thu Apr 6 2:10: 6 2000 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id 39C5837BB68 for ; Thu, 6 Apr 2000 02:10:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id CAA43561; Thu, 6 Apr 2000 02:10:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id 342E537BB68 for ; Thu, 6 Apr 2000 02:06:54 -0700 (PDT) (envelope-from nobody@FreeBSD.org) Received: (from nobody@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id CAA43220; Thu, 6 Apr 2000 02:06:54 -0700 (PDT) (envelope-from nobody@FreeBSD.org) Message-Id: <200004060906.CAA43220@freefall.freebsd.org> Date: Thu, 6 Apr 2000 02:06:54 -0700 (PDT) From: jdg@debian.org To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-1.0 Subject: bin/17824: [PATCH] /usr/bin/column has arithmetic overflows Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 17824 >Category: bin >Synopsis: [PATCH] /usr/bin/column has arithmetic overflows >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Apr 6 02:10:01 PDT 2000 >Closed-Date: >Last-Modified: >Originator: Julian Gilbey >Release: I'm not (but it's still a bug in latest CVS) >Organization: >Environment: N/A >Description: I discovered that column gave divide-by-zero errors in certain situations (specifically, if the number of display columns is c and the widest item of data has width w, then letting w8 = 8*((w+8)/8) (rounding down to the nearest int), the error will occur if wHow-To-Repeat: polya:~ $ cat > /tmp/72 123456789012345678901234567890123456789012345678901234567890123456789012 polya:~ $ column -c 79 Fix: [This patch won't work directly because of tab->space conversion.] --- column.c.orig Thu Mar 25 02:47:47 1999 +++ column.c Wed Apr 5 23:42:31 2000 @@ -145,6 +145,10 @@ maxlength = (maxlength + TAB) & ~(TAB - 1); numcols = termwidth / maxlength; + if (!numcols) { + print(); + exit(eval); + } endcol = maxlength; for (chcnt = col = 0, lp = list;; ++lp) { chcnt += printf("%s", *lp); @@ -173,6 +177,10 @@ maxlength = (maxlength + TAB) & ~(TAB - 1); numcols = termwidth / maxlength; + if (!numcols) { + print(); + exit(eval); + } numrows = entries / numcols; if (entries % numcols) ++numrows; >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message