Skip to content

Commit

Permalink
radosgw-admin: fix crash with 'sync flow create/remove' cmd
Browse files Browse the repository at this point in the history
Avoid dereferencing an empty optional "flow-type" (if not specified).

Fixes: https://tracker.ceph.com/issues/57275

Signed-off-by: Soumya Koduri <skoduri@redhat.com>
  • Loading branch information
soumyakoduri committed Sep 1, 2022
1 parent 0c55bf3 commit 539c5b8
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/rgw/rgw_admin.cc
Expand Up @@ -9385,10 +9385,11 @@ int main(int argc, const char **argv)
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();
Expand Down Expand Up @@ -9435,10 +9436,11 @@ int main(int argc, const char **argv)
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();
Expand Down

0 comments on commit 539c5b8

Please sign in to comment.