]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd.cc: add check to prevent null deref in rbd_list()
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Wed, 3 Sep 2014 20:59:30 +0000 (22:59 +0200)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Wed, 3 Sep 2014 20:59:30 +0000 (22:59 +0200)
Fix for :

CID 1192467 (2 of 2): Explicit null dereferenced (FORWARD_NULL)
 var_deref_model: Passing null pointer ibuf to rbd_list,
 which dereferences it.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
src/librbd/librbd.cc

index 24e191adfd0f166c4a364b7490df31f27071b5ba..cde6dd98e10eea80ac5eabe08fc056c0f17e6931 100644 (file)
@@ -633,6 +633,9 @@ extern "C" int rbd_list(rados_ioctx_t p, char *names, size_t *size)
     return -ERANGE;
   }
 
+  if (!names) 
+    return -EINVAL;
+
   for (int i = 0; i < (int)cpp_names.size(); i++) {
     strcpy(names, cpp_names[i].c_str());
     names += strlen(names) + 1;