idtree: fix right shift of signed ints, crash on large ids on AIX
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 5 Oct 2010 02:36:19 +0000 (13:06 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Thu, 7 Oct 2010 04:54:46 +0000 (15:24 +1030)
commit53d49df2d4519c35b270c30660e2504af2a5ed5c
tree7e19667dd2499f397b3f24e6170bef636fe87cc0
parent2b81314eb94d31f4efadd2a3dcf2f6e176338d3f
idtree: fix right shift of signed ints, crash on large ids on AIX

Right-shifting signed integers in undefined; indeed it seems that on
AIX with their compiler, doing a 30-bit shift on (INT_MAX-200) gives
0, not 1 as we might expect.

The obvious fix is to make id and oid unsigned: l (level count) is also
logically unsigned.

(Note: Samba doesn't generally get to ids > 1 billion, but ctdb does)

Reported-by: Chris Cowan <cc@us.ibm.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-User: Rusty Russell <rusty@samba.org>
Autobuild-Date: Wed Oct  6 08:31:09 UTC 2010 on sn-devel-104
lib/util/idtree.c