From: hyun-ha Date: Fri, 22 Jun 2018 16:10:20 +0000 (+0900) Subject: librbd: block_name_prefix is not created randomly X-Git-Tag: v14.0.1~321^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F22675%2Fhead;p=ceph.git librbd: block_name_prefix is not created randomly fixes: http://tracker.ceph.com/issues/24634 Signed-off-by: hyun ha hyun.ha@navercorp.com --- diff --git a/src/librbd/Utils.cc b/src/librbd/Utils.cc index d4b4c94914ff..a858ddf857c3 100644 --- a/src/librbd/Utils.cc +++ b/src/librbd/Utils.cc @@ -11,6 +11,7 @@ #include "common/dout.h" #include "librbd/ImageCtx.h" #include "librbd/Features.h" +#include #define dout_subsys ceph_subsys_rbd #undef dout_prefix @@ -51,7 +52,9 @@ std::string generate_image_id(librados::IoCtx &ioctx) { librados::Rados rados(ioctx); uint64_t bid = rados.get_instance_id(); - uint32_t extra = rand() % 0xFFFFFFFF; + std::mt19937 generator{std::random_device{}()}; + std::uniform_int_distribution distribution{0, 0xFFFFFFFF}; + uint32_t extra = distribution(generator); ostringstream bid_ss; bid_ss << std::hex << bid << std::hex << extra;