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, 9 Jun 2010 23:25:56 +0000 (08:55 +0930)
commit32c04e11ebbcf8239e47016302c6ce802a8b0a6f
tree85f49d11dbb8e6f6cc97d16e78e03b991e4d8b86
parent18168da84a6aa8d69465e43402444c7ec979604a
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