aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmit Kapila <akapila@postgresql.org>2023-11-09 09:26:40 +0530
committerAmit Kapila <akapila@postgresql.org>2023-11-09 09:26:40 +0530
commita7db71ed2787e7dbf2c41473a2b7df2fcb55abd0 (patch)
tree2ae3c9bb3ea8772e48f79ae37141b9416b32a1b6
parent108161bcb9cc6df45ed9200ca935c63b2cad4666 (diff)
downloadpostgresql-a7db71ed2787e7dbf2c41473a2b7df2fcb55abd0.tar.gz
postgresql-a7db71ed2787e7dbf2c41473a2b7df2fcb55abd0.zip
Fix uninitialized slot array access during the upgrade.
Commit 29d0a77fa introduced fetching slot information from the old cluster but didn't initialize the required array in all the code paths. So when trying to access the array in verbose mode for the new cluster, it leads to an uninitialized memory access. Author: Vignesh C Discussion: http://postgr.es/m/CALDaNm1tntGP5=CtMz=v+k3_PGv7kE9t6iWSgX-QiurAaFkhZw@mail.gmail.com
-rw-r--r--src/bin/pg_upgrade/info.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/bin/pg_upgrade/info.c b/src/bin/pg_upgrade/info.c
index 7f21d26fd23..4878aa22bfd 100644
--- a/src/bin/pg_upgrade/info.c
+++ b/src/bin/pg_upgrade/info.c
@@ -408,7 +408,7 @@ get_db_infos(ClusterInfo *cluster)
i_spclocation = PQfnumber(res, "spclocation");
ntups = PQntuples(res);
- dbinfos = (DbInfo *) pg_malloc(sizeof(DbInfo) * ntups);
+ dbinfos = (DbInfo *) pg_malloc0(sizeof(DbInfo) * ntups);
for (tupnum = 0; tupnum < ntups; tupnum++)
{
@@ -636,15 +636,11 @@ get_old_cluster_logical_slot_infos(DbInfo *dbinfo, bool live_check)
PGconn *conn;
PGresult *res;
LogicalSlotInfo *slotinfos = NULL;
- int num_slots = 0;
+ int num_slots;
/* Logical slots can be migrated since PG17. */
if (GET_MAJOR_VERSION(old_cluster.major_version) <= 1600)
- {
- dbinfo->slot_arr.slots = slotinfos;
- dbinfo->slot_arr.nslots = num_slots;
return;
- }
conn = connectToServer(&old_cluster, dbinfo->db_name);