]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: NULL terminate buffer before parsing it
authorYehuda Sadeh <yehuda@inktank.com>
Wed, 11 Sep 2013 20:46:31 +0000 (13:46 -0700)
committerYehuda Sadeh <yehuda@inktank.com>
Thu, 19 Sep 2013 20:07:30 +0000 (13:07 -0700)
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 <josh.durgin@inktank.com>
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
(cherry picked from commit e7f7483192cddca1159aba439ce62b1e78669d51)

src/rgw/rgw_rados.cc

index d79fbe4c943c233163c60fca8c07037be2a296d3..bada7d22d1b6929d4cfec0e7676e086fa493a646 100644 (file)
@@ -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;