Fix bogus initialization of replication origin shared memory state.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 15 May 2020 23:05:39 +0000 (19:05 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 15 May 2020 23:05:39 +0000 (19:05 -0400)
commit8048404939bb0fcef80b0ab57910b6e10d4289a3
tree53bf662e5afde4fe42c118a09f6f7cd5fbf96464
parent36ac359d3621578cefc2156a3917024cdd3b1829
Fix bogus initialization of replication origin shared memory state.

The previous coding zeroed out offsetof(ReplicationStateCtl, states)
more bytes than it was entitled to, as a consequence of starting the
zeroing from the wrong pointer (or, if you prefer, using the wrong
calculation of how much to zero).

It's unsurprising that this has not caused any reported problems,
since it can be expected that the newly-allocated block is at the end
of what we've used in shared memory, and we always make the shmem
block substantially bigger than minimally necessary.  Nonetheless,
this is wrong and it could bite us someday; plus it's a dangerous
model for somebody to copy.

This dates back to the introduction of this code (commit 5aa235042),
so back-patch to all supported branches.
src/backend/replication/logical/origin.c