From owner-freebsd-bugs Thu Apr 6 9:30: 7 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 CB59C37B6DC for ; Thu, 6 Apr 2000 09:30:04 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id JAA56519; Thu, 6 Apr 2000 09:30:04 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Date: Thu, 6 Apr 2000 09:30:04 -0700 (PDT) Message-Id: <200004061630.JAA56519@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Julian Gilbey Subject: Re: bin/17824: [PATCH] /usr/bin/column has arithmetic overflows Reply-To: Julian Gilbey Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org The following reply was made to PR bin/17824; it has been noted by GNATS. From: Julian Gilbey To: Sheldon Hearn Cc: freebsd-gnats-submit@FreeBSD.ORG Subject: Re: bin/17824: [PATCH] /usr/bin/column has arithmetic overflows Date: Thu, 6 Apr 2000 17:26:51 +0100 On Thu, Apr 06, 2000 at 02:25:53PM +0200, Sheldon Hearn wrote: > On Thu, 06 Apr 2000 02:06:54 MST, jdg@debian.org wrote: > > > maxlength = (maxlength + TAB) & ~(TAB - 1); > > numcols = termwidth / maxlength; > > + if (!numcols) { > > I don't get it. You still don't seem to be protecting against > divide-by-zero. Shouldn't you be testing the value of the dividend > before dividing? maxlength >= 0. So, assuming that TAB is 8 (which it presumably is), the first line of the code rounds maxlength up to the next multiple of 8, so maxlength >= 8 after this step. However, it is possible that numcols is zero if termwidth is less than the new maxlength, in which case we get a divide by zero in the next line (numrows = numlines / numcols or something like that). That's why I test for numcols being zero and not maxlength. Julian -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Julian Gilbey, Dept of Maths, QMW, Univ. of London. J.D.Gilbey@qmw.ac.uk Debian GNU/Linux Developer, see http://www.debian.org/~jdg Donate free food to the world's hungry: see http://www.thehungersite.com/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message