From: Abhishek Lekshmanan Date: Fri, 9 Jun 2017 13:27:25 +0000 (+0200) Subject: rgw: don't specify a length when convert bl -> string X-Git-Tag: v12.1.0~64^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b38bda730dd9a0112024e9ecea95cd0d9c80d18f;p=ceph.git rgw: don't specify a length when convert bl -> string in rgw_admin we're assigning a string from a bufferlist by explicitly specifying a size and using assign, in this case the whole contents of the buffer are copied regardless of whether the null character is seen. Just use normal assign which would only copy until the null is encountered Fixes: http://tracker.ceph.com/issues/20037 Signed-off-by: Abhishek Lekshmanan --- diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 5a65eb5a5150..5d8ecbd08868 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -1243,7 +1243,7 @@ static bool dump_string(const char *field_name, bufferlist& bl, Formatter *f) { string val; if (bl.length() > 0) { - val.assign(bl.c_str(), bl.length()); + val.assign(bl.c_str()); } f->dump_string(field_name, val); diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 7c6c98821aca..36e2eafedaf6 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -9000,8 +9000,8 @@ int RGWRados::get_system_obj_state_impl(RGWObjectCtx *rctx, rgw_raw_obj& obj, RG s->obj_tag = s->attrset[RGW_ATTR_ID_TAG]; if (s->obj_tag.length()) - ldout(cct, 20) << "get_system_obj_state: setting s->obj_tag to " - << string(s->obj_tag.c_str(), s->obj_tag.length()) << dendl; + ldout(cct, 20) << "get_system_obj_state: setting s->obj_tag to " + << s->obj_tag.c_str() << dendl; else ldout(cct, 20) << "get_system_obj_state: s->obj_tag was set empty" << dendl; @@ -9152,7 +9152,7 @@ int RGWRados::get_obj_state_impl(RGWObjectCtx *rctx, const RGWBucketInfo& bucket } } if (s->obj_tag.length()) - ldout(cct, 20) << "get_obj_state: setting s->obj_tag to " << string(s->obj_tag.c_str(), s->obj_tag.length()) << dendl; + ldout(cct, 20) << "get_obj_state: setting s->obj_tag to " << s->obj_tag.c_str() << dendl; else ldout(cct, 20) << "get_obj_state: s->obj_tag was set empty" << dendl;