idtree: fix right shift of signed ints, crash on large ids on AIX
commitbca6ebb65dfac92534756338952005d1ff98eafd
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 5 Oct 2010 02:36:19 +0000 (5 13:06 +1030)
committerJeremy Allison <jra@samba.org>
Wed, 6 Oct 2010 17:14:35 +0000 (6 10:14 -0700)
tree0d6978d7e7bb7bf254c111f92348d7aa3bb1a586
parentbd897350cc5c5f9cd77917630a632dc4ca3efd6d
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
(cherry picked from commit 2db1987f5a3a4268ce64fe570ff598e3bf4ecc73)
lib/util/idtree.c