Skip to content

Remove noop from change key provider #283

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

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions contrib/pg_tde/src/catalog/tde_keyring.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,19 +213,12 @@ pg_tde_change_key_provider_internal(PG_FUNCTION_ARGS, Oid dbOid)
char *provider_type = text_to_cstring(PG_GETARG_TEXT_PP(0));
char *provider_name = text_to_cstring(PG_GETARG_TEXT_PP(1));
char *options = text_to_cstring(PG_GETARG_TEXT_PP(2));
int nlen,
olen;
int olen;
KeyringProviderRecord provider;

/* reports error if not found */
GenericKeyring *keyring = GetKeyProviderByName(provider_name, dbOid);

nlen = strlen(provider_name);
if (nlen >= sizeof(provider.provider_name))
ereport(ERROR,
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("too long provider name, maximum length is %ld bytes", sizeof(provider.provider_name) - 1));

olen = strlen(options);
if (olen >= sizeof(provider.options))
ereport(ERROR,
Expand All @@ -235,7 +228,7 @@ pg_tde_change_key_provider_internal(PG_FUNCTION_ARGS, Oid dbOid)
/* Struct will be saved to disk so keep clean */
memset(&provider, 0, sizeof(provider));
provider.provider_id = keyring->keyring_id;
memcpy(provider.provider_name, provider_name, nlen);
memcpy(provider.provider_name, provider_name, strlen(provider_name));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we instead copy from keyring.provider_name to make the intent clearer plus not change the case just because we change the values?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we should. but changing that behavior is out of scope for this PR. I intended to do that separately as well, but with a test for it included. Just didn't have time before the standup.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR was mostly to protect #267 from questions about why an unrelated error message wasn't updated 😆 .

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have done it as part of this PR if I were you but this is an improvment either way.

memcpy(provider.options, options, olen);
provider.provider_type = get_keyring_provider_from_typename(provider_type);

Expand Down