]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rbd: null check before pool_name use
authoramitkuma <amitkuma@redhat.com>
Tue, 7 Nov 2017 18:26:02 +0000 (23:56 +0530)
committeramitkuma <amitkuma@redhat.com>
Tue, 21 Nov 2017 15:56:50 +0000 (21:26 +0530)
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 <amitkuma@redhat.com>
src/tools/rbd/Utils.cc

index d3c2bb13a5308493dc65965b4f06a1e969e0a8b1..f631900e3c648d6631ee98d0548fa07679a8fb42 100644 (file)
@@ -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;
     }