On Tue, Feb 17, 2009 at 03:12:05PM +0100, Philipp Kolmann wrote:
> Hi,
>
> we found some discussion about this issue here:
>
> http://www.velocityreviews.com/forums/t283343-shifting-bits-shift-32-bits-on-32-bit-int.html
>
> In post #4 it reads:
> The behaviour of shifts defined only if the value of the right operand  
> is less than the number of bits in the left operand. So shifting a  
> 32-bit value by 32 or more is undefined...
>
> further info in #7:
>
> Better yet, read the first part of section 5.8 of the ISO/IEC 14882:2003
> standard:
>
> The behavior is undefined if the right operand is negative,
> or greater than or equal to the length in bits of the
> promoted left operand.
>
> So it seems that my patch is the proper fix in the end after all.  
> Attached as file, since BT distroyed the formatting.
>
> Thanks
> Philipp

> --- IPv6addr.c_ORIG   2009-02-17 14:28:45.000000000 +0100
> +++ IPv6addr.c        2009-02-17 14:29:24.000000000 +0100
> @@ -487,7 +487,10 @@
>                       n = plen / 32;
>                       memset(mask.s6_addr32 + n + 1, 0, (3 - n) * 4);
>                       s = 32 - plen % 32;
> -                     mask.s6_addr32[n] = 0xffffffff << s;
> +                     if (s == 32) 
> +                             mask.s6_addr32[n] = 0x0;
> +                     else
> +                             mask.s6_addr32[n] = 0xffffffff << s;
>                       mask.s6_addr32[n] = htonl(mask.s6_addr32[n]);
>               }
>  

Hi Phillipp,

this looks like a good fix to me, how well tested is it?

I'm embarrassed to say that this problem was introduced by me the last time
that I tried to fix this code [1].

http://hg.vergenet.net/linux-ha/dev/rev/774ee922abe7

-- 
Simon Horman
  VA Linux Systems Japan K.K., Sydney, Australia Satellite Office
  H: www.vergenet.net/~horms/             W: www.valinux.co.jp/en




-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to