From 91931a38ce280132e270c80822f3f3b2cc0a3bf9 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Wed, 4 May 2022 16:19:01 -0400 Subject: [PATCH] radosgw-admin: don't crash on --placement-id without --storage-class if --storage-class is omitted, avoid dereferencing an empty optional Fixes: https://tracker.ceph.com/issues/55548 Signed-off-by: Casey Bodley --- src/rgw/rgw_admin.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 8b87ab0b6ce..76efc2e116e 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -6169,11 +6169,10 @@ int main(int argc, const char **argv) else if (opt_cmd == OPT::USER_SUSPEND) user_op.set_suspension(true); - if (!placement_id.empty() || - (opt_storage_class && !opt_storage_class->empty())) { + if (!placement_id.empty()) { rgw_placement_rule target_rule; target_rule.name = placement_id; - target_rule.storage_class = *opt_storage_class; + target_rule.storage_class = opt_storage_class.value_or(""); if (!store->valid_placement(target_rule)) { cerr << "NOTICE: invalid dest placement: " << target_rule.to_str() << std::endl; return EINVAL; -- 2.39.5