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

Use postgres mem context in decryption #6

Merged
merged 2 commits into from
Aug 23, 2023
Merged
Changes from 1 commit
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
7 changes: 6 additions & 1 deletion src/encryption/enc_tuple.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define ENCRYPTION_DEBUG 1

#include "postgres.h"
#include "utils/memutils.h"

#include "encryption/enc_tuple.h"
#include "encryption/enc_aes.h"
Expand Down Expand Up @@ -79,8 +80,12 @@ static void PGTdeDecryptTupInternal2(BlockNumber bn, Page page, HeapTuple tuple,
// Most of the time we can't decrypt in place, so we allocate some memory... and leek it for now :(
Copy link
Collaborator

Choose a reason for hiding this comment

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

This comment is no longer true with these changes.

Copy link
Member Author

Choose a reason for hiding this comment

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

yep, I even checked if there is no comment about the leak - thought it was right above malloc :)
fixed 0738044

if(allocNew)
{
newPtr = malloc(tuple->t_len);
MemoryContext oldctx = MemoryContextSwitchTo(CurTransactionContext);

newPtr = palloc(tuple->t_len);
memcpy(newPtr, tuple->t_data, tuple->t_len);

MemoryContextSwitchTo(oldctx);
}

PGTdeDecryptTupInternal(tuple->t_tableOid, bn, page, tuple->t_data, newPtr, from, to);
Expand Down