From 21489acffebbcb2663e8a15e988f8902c4e689e6 Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Mon, 13 May 2013 16:19:46 +0200 Subject: [PATCH] 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 --- src/rbd.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rbd.cc b/src/rbd.cc index 3e586bd4dcbab..5e7389162f2f2 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); -- 2.39.5