Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rgw/backport/pacific: Fix crashes with Sync policy APIs #47994

Merged
merged 2 commits into from Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 10 additions & 8 deletions src/rgw/rgw_admin.cc
Expand Up @@ -8452,10 +8452,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 @@ -8502,10 +8503,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
4 changes: 4 additions & 0 deletions src/rgw/rgw_sync_policy.cc
Expand Up @@ -256,6 +256,10 @@ void rgw_sync_bucket_entities::set_bucket(std::optional<string> tenant,
bucket.emplace();
}

if (!bucket) {
return;
}

set_bucket_field(tenant, &bucket->tenant);
set_bucket_field(bucket_name, &bucket->name);
set_bucket_field(bucket_id, &bucket->bucket_id);
Expand Down