Re: [PATCH] fs/partitions/msdos.c Guard against negative sizes

From: Ph. Marek (philipp.marek@bmlv.gv.at)
Date: Mon Jan 27 2003 - 10:38:47 EST


> > u32 size = NR_SECTS(p)*sector_size;
> > - if (!size)
> > + if (size <= 0)
>
> But an unsigned variable cannot be negative, so what you write
> is the same as what was there already.
>
> In other words, your "negative" sizes are just very large positive.
>
> The test should be whether the partition extends beyond the end
> of the disk, but sometimes that is allowed, even necessary, so
> there could be a warning only.
Sorry, didn't pay enough attention.
On second look: it's an u32.
But that brings the next question up: what about overflow? u32 means a max of
4GB.
        u32 start = START_SECT(p)*sector_size;
        u32 size = NR_SECTS(p)*sector_size;
And this looks as if it was calculated in bytes - but I'm sure that 4GB is not
the max size! Where am I wrong??

And btw, when can a partition that extends beyond the end be "allowed or even
necessary"?

Thanks for your answer!

Regards,

Phil

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Jan 31 2003 - 22:00:16 EST