From: amitkuma Date: Tue, 7 Nov 2017 18:26:02 +0000 (+0530) Subject: rbd: null check before pool_name use X-Git-Tag: v13.0.1~139^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F18790%2Fhead;p=ceph.git rbd: null check before pool_name use Fixes the coverity issue: CID 1394846 (#1 of 1): Dereference after null check (FORWARD_NULL) 15. var_deref_model: Passing null pointer pool_name to regex_match, which dereferences it. Signed-off-by: Amit Kumar --- diff --git a/src/tools/rbd/Utils.cc b/src/tools/rbd/Utils.cc index d3c2bb13a53..f631900e3c6 100644 --- a/src/tools/rbd/Utils.cc +++ b/src/tools/rbd/Utils.cc @@ -442,7 +442,7 @@ int get_pool_image_snapshot_names(const po::variables_map &vm, //Validate pool name while creating/renaming/copying/cloning/importing/etc if (spec_validation == SPEC_VALIDATION_FULL) { boost::regex pattern("^[^@/]+?$"); - if (!boost::regex_match (*pool_name, pattern)) { + if ((pool_name != nullptr) && !boost::regex_match (*pool_name, pattern)) { std::cerr << "rbd: invalid pool name '" << *pool_name << "'" << std::endl; return -EINVAL; }