summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2022-06-07 19:34:30 +0000
committerTom Lane2022-06-07 19:34:30 +0000
commita36196972b77228882cab7838eed52c1a9154e4a (patch)
treeb0bf31909a955edc8a5bd7ef0fdc1ce884057f0d
parent16d68007cd7400061bd499b92eb80fbb9798362c (diff)
Fix off-by-one loop termination condition in pg_stat_get_subscription().
pg_stat_get_subscription scanned one more LogicalRepWorker array entry than is really allocated. In the worst case this could lead to SIGSEGV, if the LogicalRepCtx data structure is near the end of shared memory. That seems quite unlikely though (thanks to the ordering of calls in CreateSharedMemoryAndSemaphores) and we've heard no field reports of it. A more likely misbehavior is one row of garbage data in the function's result, but even that is not real likely because of the check that the pid field matches some live backend. Report and fix by Kuntal Ghosh. This bug is old, so back-patch to all supported branches. Discussion: https://postgr.es/m/CAGz5QCJykEDzW6jQK6Yz7Qh_PMtD=95de_7QoocbVR2Qy8hWZA@mail.gmail.com
-rw-r--r--src/backend/replication/logical/launcher.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/backend/replication/logical/launcher.c b/src/backend/replication/logical/launcher.c
index 50993765f2f..27d4fb7d3c7 100644
--- a/src/backend/replication/logical/launcher.c
+++ b/src/backend/replication/logical/launcher.c
@@ -1106,7 +1106,7 @@ pg_stat_get_subscription(PG_FUNCTION_ARGS)
/* Make sure we get consistent view of the workers. */
LWLockAcquire(LogicalRepWorkerLock, LW_SHARED);
- for (i = 0; i <= max_logical_replication_workers; i++)
+ for (i = 0; i < max_logical_replication_workers; i++)
{
/* for each row */
Datum values[PG_STAT_GET_SUBSCRIPTION_COLS];