From b38bda730dd9a0112024e9ecea95cd0d9c80d18f Mon Sep 17 00:00:00 2001 From: Abhishek Lekshmanan Date: Fri, 9 Jun 2017 15:27:25 +0200 Subject: [PATCH] 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 --- src/rgw/rgw_admin.cc | 2 +- src/rgw/rgw_rados.cc | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 5a65eb5a515..5d8ecbd0886 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 7c6c98821ac..36e2eafedaf 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; -- 2.47.3