]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix potential null pointer dereference in rgw_admin. 15667/head
authorRadoslaw Zarzynski <rzarzynski@mirantis.com>
Tue, 13 Jun 2017 11:31:18 +0000 (13:31 +0200)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Thu, 22 Jun 2017 16:39:22 +0000 (12:39 -0400)
The recent Static Analysis for Ceph (linked 13 June 2017 on
ceph-devel) shows that the send_to_remote_gateway of rgw_admin
potentially dereferences a null pointer. This commit rectifies
that behaviour.

Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/rgw/rgw_admin.cc

index 5a65eb5a5150824b639989b649ed69acf44275dc..097078630510c7fb90f82334bd12179d235ad93b 100644 (file)
@@ -1585,13 +1585,19 @@ static boost::optional<RGWRESTConn> get_remote_conn(RGWRados *store,
   return conn;
 }
 
-#define MAX_REST_RESPONSE (128 * 1024) // we expect a very small response
+// we expect a very small response
+static constexpr size_t MAX_REST_RESPONSE = 128 * 1024;
+
 static int send_to_remote_gateway(RGWRESTConn* conn, req_info& info,
                                   bufferlist& in_data, JSONParser& parser)
 {
-  bufferlist response;
+  if (!conn) {
+    return -EINVAL;
+  }
+
+  ceph::bufferlist response;
   rgw_user user;
-  int ret = conn->forward(user, info, NULL, MAX_REST_RESPONSE, &in_data, &response);
+  int ret = conn->forward(user, info, nullptr, MAX_REST_RESPONSE, &in_data, &response);
 
   int parse_ret = parser.parse(response.c_str(), response.length());
   if (parse_ret < 0) {