]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librados: fix use without NULL check in rados_pool_list
authorJosh Durgin <josh.durgin@inktank.com>
Mon, 24 Sep 2012 22:03:56 +0000 (15:03 -0700)
committerSamuel Just <sam.just@inktank.com>
Tue, 25 Sep 2012 21:09:27 +0000 (14:09 -0700)
CID 716911: Dereference after null check (FORWARD_NULL)
At (5): Passing null pointer "b" to function "strncat(char *, char
const *, size_t)", which dereferences it. (The dereference is assumed
on the basis of the 'nonnull' parameter attribute.)

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
src/librados/librados.cc

index 5aad1a64c7e65d701b20edc12e2626f7f353602a..82721a96aa5dda347fa999f9eadb3a586abf031f 100644 (file)
@@ -1483,6 +1483,9 @@ extern "C" int rados_pool_list(rados_t cluster, char *buf, size_t len)
   std::list<std::string> pools;
   client->pool_list(pools);
 
+  if (!buf)
+    return -EINVAL;
+
   char *b = buf;
   if (b)
     memset(b, 0, len);