Subject: Re: reproduceable "integer divide fault trap"
To: Pavel Cahyna <pavel.cahyna@st.mff.cuni.cz>
From: David Laight <david@l8s.co.uk>
List: netbsd-help
Date: 11/27/2005 11:45:30
On Sun, Nov 27, 2005 at 11:21:04AM +0100, Pavel Cahyna wrote:
> On Sun, Nov 27, 2005 at 08:50:55AM +0000, David Laight wrote:
> > On Sat, Nov 26, 2005 at 10:08:07PM -0600, Jonathan A. Kollasch wrote:
> > > 
> > >         cgsize = fs->fs_fsize * fs->fs_fpg;
> > >         dirsize = fs->fs_avgfilesize * fs->fs_avgfpdir;
> > > # fs->fs_avgfilesize == 0x40000000, fs->fs_avgfpdir == 0x20
> > 
> > fs_avgfilesize and fs_avgfpdir are both int32_t, dirsize is bound to be wrong
> > if the product is > 2^31.
> 
> cgsize has the same problem as fs_fsize and fs_fpg are also int32_t.

Indeed, the divide by zero can only happen if cgsize comes out -ve.

	David

-- 
David Laight: david@l8s.co.uk