]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Clear padding of PgStat_HashKey when handling pgstats entries
authorMichael Paquier <michael@paquier.xyz>
Tue, 5 Nov 2024 00:41:01 +0000 (09:41 +0900)
committerMichael Paquier <michael@paquier.xyz>
Tue, 5 Nov 2024 00:41:01 +0000 (09:41 +0900)
commit6d5e6693ee6bd08ed47713c808dbd281cf9cf9cd
tree291e8583fcfe2aed75dc6c7cd2021d9ebf9729c5
parentd14e94ac45795f5bf55ba80b2a6f5acd02702e0f
Clear padding of PgStat_HashKey when handling pgstats entries

PgStat_HashKey is currently initialized in a way that could result in
random data if the structure has any padding bytes.  The structure
has no padding bytes currently, fortunately, but it could become a
problem should the structure change at some point in the future.

The code is changed to use some memset(0) so as any padding would be
handled properly, as it would be surprising to see random failures in
the pgstats entry lookups.  PgStat_HashKey is a structure internal to
pgstats, and an ABI change could be possible in the scope of a bug fix,
so backpatch down to 15 where this has been introduced.

Author: Bertrand Drouvot
Reviewed-by: Jelte Fennema-Nio, Michael Paquier
Discussion: https://postgr.es/m/Zyb7RW1y9dVfO0UH@ip-10-97-1-34.eu-west-3.compute.internal
Backpatch-through: 15
src/backend/utils/activity/pgstat.c
src/backend/utils/activity/pgstat_shmem.c