From: Yehuda Sadeh Date: Wed, 11 Sep 2013 20:46:31 +0000 (-0700) Subject: rgw: NULL terminate buffer before parsing it X-Git-Tag: v0.67.4~28 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=daf85c45dd4d158bc7c33a2fb784857bc7db35cd;p=ceph.git rgw: NULL terminate buffer before parsing it Fixes: #6175 Backport: dumpling 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(). Reviewed-by: Josh Durgin Signed-off-by: Yehuda Sadeh (cherry picked from commit e7f7483192cddca1159aba439ce62b1e78669d51) --- diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index d79fbe4c943c..bada7d22d1b6 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -2616,6 +2616,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;