From 55c25726c4c980ac0ad919227e6d6a61c21839fe Mon Sep 17 00:00:00 2001 From: amitkuma Date: Tue, 7 Nov 2017 23:56:02 +0530 Subject: [PATCH] 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 --- src/tools/rbd/Utils.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/rbd/Utils.cc b/src/tools/rbd/Utils.cc index d3c2bb13a530..f631900e3c64 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; } -- 2.47.3