From: Radoslaw Zarzynski Date: Tue, 13 Jun 2017 11:31:18 +0000 (+0200) Subject: rgw: fix potential null pointer dereference in rgw_admin. X-Git-Tag: v12.1.1~1^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=cebbf958be3e459749e2227b5a8e0e13d9bf0478;p=ceph.git rgw: fix potential null pointer dereference in rgw_admin. 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 Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 5a65eb5a5150..097078630510 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -1585,13 +1585,19 @@ static boost::optional 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) {