From: Danny Al-Gaaf Date: Mon, 13 May 2013 14:19:46 +0000 (+0200) Subject: src/rbd.cc: use 64-bits to shift 'order' X-Git-Tag: v0.63~29^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=21489acffebbcb2663e8a15e988f8902c4e689e6;p=ceph.git src/rbd.cc: use 64-bits to shift 'order' 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 --- diff --git a/src/rbd.cc b/src/rbd.cc index 3e586bd4dcba..5e7389162f2f 100644 --- a/src/rbd.cc +++ b/src/rbd.cc @@ -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);