idtree: fix handling of large ids (eg INT_MAX)
authorRusty Russell <rusty@rustcorp.com.au>
Wed, 9 Jun 2010 23:25:56 +0000 (08:55 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Wed, 30 Jun 2010 05:20:58 +0000 (14:50 +0930)
commit7d4658d3fc09560ccf16b304ffdb5391a2b48f72
tree9b88121c865a914ed53618da5aafca85b2db8fea
parent18bf912059cd01a8854ad52c664eb0b3fc957dee
idtree: fix handling of large ids (eg INT_MAX)

Since idtree assigns sequentially, it rarely reaches high numbers.
But such numbers can be forced with idr_get_new_above(), and that
reveals two bugs:
1) Crash in sub_remove() caused by pa array being too short.
2) Shift by more than 32 in _idr_find(), which is undefined, causing
   the "outside the current tree" optimization to misfire and return NULL.

Signed-off-by: Rusty Russell <rusty@rustorp.com.au>
lib/util/idtree.c