]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
radosgw-admin: don't crash on --placement-id without --storage-class 53473/head
authorCasey Bodley <cbodley@redhat.com>
Wed, 4 May 2022 20:19:01 +0000 (16:19 -0400)
committerKonstantin Shalygin <k0ste@k0ste.ru>
Thu, 14 Sep 2023 19:11:33 +0000 (02:11 +0700)
if --storage-class is omitted, avoid dereferencing an empty optional

Fixes: https://tracker.ceph.com/issues/55548
Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 91931a38ce280132e270c80822f3f3b2cc0a3bf9)

Conflicts:
  - path: src/rgw/rgw_admin.cc
    comment: resolve minor conflict

src/rgw/rgw_admin.cc

index 9fd01ecc613811befff045acb2686929db726880..fd9812f3cd04becf2a3459f1342d6b04a7b6b695 100644 (file)
@@ -6159,11 +6159,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->get_zone()->get_params().valid_placement(target_rule)) {
       cerr << "NOTICE: invalid dest placement: " << target_rule.to_str() << std::endl;
       return EINVAL;