From 46fd70a6086d6d876a102844fcdc203c1bf46bfd Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Wed, 11 Sep 2013 13:46:31 -0700 Subject: rgw: NULL terminate buffer before parsing it Fixes: #6175 We get a buffer off the remote gateway which might not be NULL terminated. The JSON parser needs the buffer to be NULL terminated even though we provide a buffer length as it calls strlen(). Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_rados.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 0c2119ecf9d..8fa19060277 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -2611,6 +2611,7 @@ int RGWRados::copy_obj(void *ctx, { /* opening scope so that we can do goto, sorry */ bufferlist& extra_data_bl = processor.get_extra_data(); if (extra_data_bl.length()) { + extra_data_bl.push_back((char)0); JSONParser jp; if (!jp.parse(extra_data_bl.c_str(), extra_data_bl.length())) { ldout(cct, 0) << "failed to parse response extra data. len=" << extra_data_bl.length() << " data=" << extra_data_bl.c_str() << dendl; -- cgit v1.2.1