From 09bfe49d8f8862f598bb21d05ee3c750170ad6d8 Mon Sep 17 00:00:00 2001 From: Soumya Koduri Date: Wed, 24 Aug 2022 11:08:38 +0530 Subject: [PATCH] radosgw-admin: fix crash with 'sync flow create/remove' cmd Avoid dereferencing an empty optional "flow-type" (if not specified). Fixes: https://tracker.ceph.com/issues/57275 Signed-off-by: Soumya Koduri (cherry picked from commit 539c5b87a2965ce43002430790abd586b98f620d) --- src/rgw/rgw_admin.cc | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index a3f8f38cae94..a18ac23d7807 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -8993,10 +8993,11 @@ next: if (opt_cmd == OPT::SYNC_GROUP_FLOW_CREATE) { CHECK_TRUE(require_opt(opt_group_id), "ERROR: --group-id not specified", EINVAL); CHECK_TRUE(require_opt(opt_flow_id), "ERROR: --flow-id not specified", EINVAL); - CHECK_TRUE(require_opt(opt_flow_type, - (symmetrical_flow_opt(*opt_flow_type) || - directional_flow_opt(*opt_flow_type))), - "ERROR: --flow-type not specified or invalid (options: symmetrical, directional)", EINVAL); + CHECK_TRUE(require_opt(opt_flow_type), + "ERROR: --flow-type not specified (options: symmetrical, directional)", EINVAL); + CHECK_TRUE((symmetrical_flow_opt(*opt_flow_type) || + directional_flow_opt(*opt_flow_type)), + "ERROR: --flow-type invalid (options: symmetrical, directional)", EINVAL); SyncPolicyContext sync_policy_ctx(zonegroup_id, zonegroup_name, opt_bucket); ret = sync_policy_ctx.init(); @@ -9043,10 +9044,11 @@ next: if (opt_cmd == OPT::SYNC_GROUP_FLOW_REMOVE) { CHECK_TRUE(require_opt(opt_group_id), "ERROR: --group-id not specified", EINVAL); CHECK_TRUE(require_opt(opt_flow_id), "ERROR: --flow-id not specified", EINVAL); - CHECK_TRUE(require_opt(opt_flow_type, - (symmetrical_flow_opt(*opt_flow_type) || - directional_flow_opt(*opt_flow_type))), - "ERROR: --flow-type not specified or invalid (options: symmetrical, directional)", EINVAL); + CHECK_TRUE(require_opt(opt_flow_type), + "ERROR: --flow-type not specified (options: symmetrical, directional)", EINVAL); + CHECK_TRUE((symmetrical_flow_opt(*opt_flow_type) || + directional_flow_opt(*opt_flow_type)), + "ERROR: --flow-type invalid (options: symmetrical, directional)", EINVAL); SyncPolicyContext sync_policy_ctx(zonegroup_id, zonegroup_name, opt_bucket); ret = sync_policy_ctx.init(); -- 2.47.3