]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
src/rbd.cc: use 64-bits to shift 'order'
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Mon, 13 May 2013 14:19:46 +0000 (16:19 +0200)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Tue, 14 May 2013 16:39:32 +0000 (18:39 +0200)
CID 1019568 (#1 of 1): Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)
  overflow_before_widen: Potentially overflowing expression "1 << *order" with
  type "int" (32 bits, signed) 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 the left operand to "uint64_t" before
  performing the left shift.

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

index 3e586bd4dcbab0eb12b9251fc640821cde5c777f..5e7389162f2f2d4ce103bbc89874ce3c6566bb52 100644 (file)
@@ -1294,7 +1294,7 @@ static int do_import(librbd::RBD &rbd, librados::IoCtx& io_ctx,
   bool from_stdin = !strcmp(path, "-");
   if (from_stdin) {
     fd = 0;
-    size = 1 << *order;
+    size = 1ULL << *order;
   } else {
     fd = open(path, O_RDONLY);