libceph: fix overflow check in crush_decode()
authorXi Wang <xi.wang@gmail.com>
Thu, 16 Feb 2012 16:55:48 +0000 (11:55 -0500)
committerAlex Elder <elder@dreamhost.com>
Thu, 22 Mar 2012 15:47:45 +0000 (10:47 -0500)
commit64486697771cbe219fffcb5c8e2ed9ca4fdf086c
treea623eebb8105ae8e7585c7faaf171729a9cbadbb
parent810339ec2fae5cbd0164b8acde7fb65652755864
libceph: fix overflow check in crush_decode()

The existing overflow check (n > ULONG_MAX / b) didn't work, because
n = ULONG_MAX / b would both bypass the check and still overflow the
allocation size a + n * b.

The correct check should be (n > (ULONG_MAX - a) / b).

Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Sage Weil <sage@newdream.net>
net/ceph/osdmap.c