postgres.git / summary / log / commit / refs

commit    e63ce9e8d6ac8dced20592c4134004640f9f5644
Author:   Daniel Gustafsson <dgustafsson@postgresql.org>
Date:     Tue Oct 26 08:40:08 2021 +0000
First released in: 15.0, 14.1

    Ensure that slots are zeroed before use
    
    The previous coding relied on the memory for the slots being zeroed
    elsewhere, which while it was true in this case is not an contract
    which is guaranteed to hold.  Explicitly clear the tts_isnull array
    to ensure that the slots are filled from a known state.
    
    Backpatch to v14 where the catalog multi-inserts were introduced.
    
    Reviewed-by: Michael Paquier <michael@paquier.xyz>
    Discussion: https://postgr.es/m/CAJ7c6TP0AowkUgNL6zcAK-s5HYsVHVBRWfu69FRubPpfwZGM9A@mail.gmail.com
    Backpatch-through: 14


src/backend/catalog/heap.c | 3 +++ src/backend/catalog/pg_shdepend.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c index 5898203972b..81cc39fb70e 100644 --- a/src/backend/catalog/heap.c +++ b/src/backend/catalog/heap.c @@ -764,6 +764,9 @@ InsertPgAttributeTuples(Relation pg_attribute_rel, ExecClearTuple(slot[slotCount]); + memset(slot[slotCount]->tts_isnull, false, + slot[slotCount]->tts_tupleDescriptor->natts * sizeof(bool)); + if (new_rel_oid != InvalidOid) slot[slotCount]->tts_values[Anum_pg_attribute_attrelid - 1] = ObjectIdGetDatum(new_rel_oid); else diff --git a/src/backend/catalog/pg_shdepend.c b/src/backend/catalog/pg_shdepend.c index 56a9a7662fd..8453d8fefd7 100644 --- a/src/backend/catalog/pg_shdepend.c +++ b/src/backend/catalog/pg_shdepend.c @@ -903,6 +903,9 @@ copyTemplateDependencies(Oid templateDbId, Oid newDbId) ExecClearTuple(slot[slot_stored_count]); + memset(slot[slot_stored_count]->tts_isnull, false, + slot[slot_stored_count]->tts_tupleDescriptor->natts * sizeof(bool)); + shdep = (Form_pg_shdepend) GETSTRUCT(tup); slot[slot_stored_count]->tts_values[Anum_pg_shdepend_dbid - 1] = ObjectIdGetDatum(newDbId); [parent: 8af09daf5629]