From: Josh Durgin Date: Mon, 24 Sep 2012 22:03:56 +0000 (-0700) Subject: librados: fix use without NULL check in rados_pool_list X-Git-Tag: v0.53~60^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a677f47926b9640c53fbd00c94d6eb7a590a94fc;p=ceph.git librados: fix use without NULL check in rados_pool_list 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 --- diff --git a/src/librados/librados.cc b/src/librados/librados.cc index 5aad1a64c7e..82721a96aa5 100644 --- a/src/librados/librados.cc +++ b/src/librados/librados.cc @@ -1483,6 +1483,9 @@ extern "C" int rados_pool_list(rados_t cluster, char *buf, size_t len) std::list pools; client->pool_list(pools); + if (!buf) + return -EINVAL; + char *b = buf; if (b) memset(b, 0, len);