Re: [PATCH] memparse bugfix

From: aq
Date: Fri Jul 15 2005 - 13:30:50 EST


On 7/16/05, Chris Wright <chrisw@xxxxxxxx> wrote:
> * aq (aquynh@xxxxxxxxx) wrote:
> > Function lib/cmdline.c:memparse() wrongly calculates the memory if the
> > given string has K/M/G suffix. This patch (against 2.6.13-rc3) fixes
> > the problem. Please apply.
>
> Patch looks incorrect.
>
> > --- 2.6.13-rc3/lib/cmdline.c 2005-04-30 10:31:37.000000000 +0900
> > +++ 2.6.13-rc3/lib/cmdline-aq.c 2005-07-16 02:25:26.000000000 +0900
> > @@ -100,10 +100,10 @@ unsigned long long memparse (char *ptr,
> > switch (**retptr) {
> > case 'G':
> > case 'g':
> > - ret <<= 10;
> > + ret <<= 30;
> > case 'M':
> > case 'm':
> > - ret <<= 10;
> > + ret <<= 20;
> > case 'K':
> > case 'k':
> > ret <<= 10;
>
> Now, G == ret << 80, M == ret << 30... Notice the fall-thru cases.
>

oops, this code doesnt use "break" like normally. what a trap!

sorry for the noise :-)

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