From 9695a0b4d169c6ae72769f39b21cee8b6e2099cf Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Thu, 18 Feb 2016 23:50:06 -0800 Subject: [PATCH] rgw: avoid empty object names Don't try to sync an object with empty name (shouldn't happen, but bugs may happen). Also, don't try to write_meta() of an empty object name, in case we get there through a different path somehow. Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_data_sync.cc | 6 ++++++ src/rgw/rgw_rados.cc | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/rgw/rgw_data_sync.cc b/src/rgw/rgw_data_sync.cc index 5d8c72f21e5..5024820eb75 100644 --- a/src/rgw/rgw_data_sync.cc +++ b/src/rgw/rgw_data_sync.cc @@ -1834,6 +1834,12 @@ public: do { yield { marker_tracker->reset_need_retry(key); + if (key.name.empty()) { + /* shouldn't happen */ + set_status("skipping empty entry"); + ldout(sync_env->cct, 0) << "ERROR: " << __func__ << "(): entry with empty obj name, skipping" << dendl; + goto done; + } if (op == CLS_RGW_OP_ADD || op == CLS_RGW_OP_LINK_OLH) { if (op == CLS_RGW_OP_ADD && !key.instance.empty() && key.instance != "null") { diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index a54757bce4d..b9d344ef323 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -5659,6 +5659,12 @@ int RGWRados::Object::Write::write_meta(uint64_t size, return r; rgw_obj& obj = target->get_obj(); + + if (obj.get_object().empty()) { + ldout(store->ctx(), 0) << "ERROR: " << __func__ << "(): cannot write object with empty name" << dendl; + return -EIO; + } + r = store->get_obj_ref(obj, &ref, &bucket); if (r < 0) return r; -- 2.47.3