Skip to content

Commit

Permalink
Updating the toasted column in encrypted table causes the crash (#82)
Browse files Browse the repository at this point in the history
pg_tde_toast_insert_or_update calls pg_tde_deform_tuple  on old-tuple from
within and tries to dereference the toast columns. Passing the encrypted tuple
as part of the old tuple renders the toast data pointer (the encrypted value
of the actual pointer) invalid, and anything can happen if it gets
dereferenced as it is.
The solution is to pass the decrypted old tuple pg_tde_toast_insert_or_update
function from pg_tde_update.
  • Loading branch information
codeforall committed Jan 19, 2024
1 parent 5dbb90b commit 1c5d265
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/access/pg_tdeam.c
Original file line number Diff line number Diff line change
Expand Up @@ -3634,7 +3634,7 @@ pg_tde_update(Relation relation, ItemPointer otid, HeapTuple newtup,
if (need_toast)
{
/* Note we always use WAL and FSM during updates */
heaptup = pg_tde_toast_insert_or_update(relation, newtup, &oldtup, 0);
heaptup = pg_tde_toast_insert_or_update(relation, newtup, &oldtup_decrypted, 0);
newtupsize = MAXALIGN(heaptup->t_len);
}
else
Expand Down

0 comments on commit 1c5d265

Please sign in to comment.