]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crush/crush.c: prevent DIVIDE_BY_ZERO
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Fri, 2 Jan 2015 21:30:24 +0000 (22:30 +0100)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Wed, 7 Jan 2015 09:14:13 +0000 (10:14 +0100)
Fix for:

CID 1219471 (#1 of 1): Division or modulo by zero (DIVIDE_BY_ZERO)
 divide_by_zero: In function call crush_make_uniform_bucket,
 division by expression item_weight which may be zero has undefined
 behavior.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
src/crush/crush.c

index 519793a02166cfce3f1454f33847d5ad103e537a..bf856fc832a83515ede48204807e7e9cc3821ab9 100644 (file)
@@ -141,6 +141,9 @@ int crush_addition_is_unsafe(__u32 a, __u32 b)
 
 int crush_multiplication_is_unsafe(__u32  a, __u32 b)
 {
+  // prevent division by zero 
+  if (!b)
+    return 1;
   if ((((__u32)(-1)) / b) < a)
     return 1;
   else