Date: Thu, 6 Apr 2000 09:30:04 -0700 (PDT) From: Julian Gilbey <J.D.Gilbey@qmw.ac.uk> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/17824: [PATCH] /usr/bin/column has arithmetic overflows Message-ID: <200004061630.JAA56519@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/17824; it has been noted by GNATS. From: Julian Gilbey <J.D.Gilbey@qmw.ac.uk> To: Sheldon Hearn <sheldonh@uunet.co.za> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200004061630.JAA56519>