]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
filer: fix overflow
authorSage Weil <sage@inktank.com>
Fri, 28 Sep 2012 14:35:20 +0000 (07:35 -0700)
committerSage Weil <sage@inktank.com>
Fri, 28 Sep 2012 20:18:06 +0000 (13:18 -0700)
CID 717017: Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)
At (1): Potentially overflowing expression "layout->fl_stripe_count.operator unsigned int() * layout->fl_object_size.operator unsigned int()" with type "unsigned int" (32 bits, unsigned) is evaluated using 32-bit arithmetic before being used in a context which expects an expression of type "uint64_t" (64 bits, unsigned). To avoid overflow, cast either operand to "uint64_t" before performing the multiplication.

+ more

Signed-off-by: Sage Weil <sage@inktank.com>
src/osdc/Filer.cc
src/osdc/Journaler.h

index 127f61b64f8e6c697df7ced0a2d504150ccd9fb6..658673e0a50c230992ff29899e833bf6fa5042c5 100644 (file)
@@ -72,7 +72,7 @@ int Filer::probe(inodeno_t ino,
   Probe *probe = new Probe(ino, *layout, snapid, start_from, end, pmtime, flags, fwd, onfinish);
   
   // period (bytes before we jump unto a new set of object(s))
-  uint64_t period = layout->fl_stripe_count * layout->fl_object_size;
+  uint64_t period = (uint64_t)layout->fl_stripe_count * (uint64_t)layout->fl_object_size;
   
   // start with 1+ periods.
   probe->probing_len = period;
@@ -194,7 +194,7 @@ void Filer::_probed(Probe *probe, const object_t& oid, uint64_t size, utime_t mt
     // keep probing!
     ldout(cct, 10) << "_probed probing further" << dendl;
 
-    uint64_t period = probe->layout.fl_stripe_count * probe->layout.fl_object_size;
+    uint64_t period = (uint64_t)probe->layout.fl_stripe_count * (uint64_t)probe->layout.fl_object_size;
     if (probe->fwd) {
       probe->probing_off += probe->probing_len;
       assert(probe->probing_off % period == 0);
index 0d954ae8ce822abce623b256ecc6066b62a6da2e..c400e26947d96cc430da46b123d80463e38fb75b 100644 (file)
@@ -309,7 +309,7 @@ public:
   uint64_t get_expire_pos() const { return expire_pos; }
   uint64_t get_trimmed_pos() const { return trimmed_pos; }
 
-  uint64_t get_layout_period() const { return layout.fl_stripe_count * layout.fl_object_size; }
+  uint64_t get_layout_period() const { return (uint64_t)layout.fl_stripe_count * (uint64_t)layout.fl_object_size; }
   ceph_file_layout& get_layout() { return layout; }
 
   // write