agora inbox for pgsql-committers@postgresql.org
help / color / mirror / Atom feedFrom: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Use more strlcpy() in two-phase transaction code
Date: Tue, 28 Jul 2026 23:55:27 +0000
Message-ID: <E1wordv-00000000jAh-3jwy@gemulon.postgresql.org> (raw)
Use more strlcpy() in two-phase transaction code
This commit replaces two calls of strcpy() and one call of strncpy() to
use strlcpy(), which are patterns that static analyzers (mostly LLMs, it
seems) have been complaining regarding buffer overflow risks.
The existing calls are safe, here are more details for each one of them:
- MarkAsPreparingGuts()'s strcpy() was guarded by MarkAsPreparing().
- PrepareRedoAdd()'s strcpy() is safe because the record-level CRC check
prevents corrupted data from reaching it unless intentionally
crafted. The replay code also assumes that the GID is within the allowed
bounds, as WAL records are trusted.
- Similarly, ParsePrepareRecord() stores its GID in a buffer bounded by
GIDSIZE while trusting the length provided by the record.
As a result, these changes are purely cosmetic. They adopt a more
defensive coding style and should also silence some of the static
analysis reports received recently.
Author: Matt Suiche <matt@tolmo.com>
Discussion: https://postgr.es/m/CAGf6Lfx2kbQfcEnCi99V2i65JSWD6ij_E29F+UkY=TyMUyeG6A@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/dd50eb9145eead17ebd62db2e43a6de7c53102c0
Modified Files
--------------
src/backend/access/rmgrdesc/xactdesc.c | 2 +-
src/backend/access/transam/twophase.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
Message-ID: <E1wordv-00000000jAh-3jwy@gemulon.postgresql.org>
Permalink: ../E1wordv-00000000jAh-3jwy@gemulon.postgresql.org/
Also on: postgresql.org/message-id/E1wordv-00000000jAh-3jwy@gemulon.postgresql.org
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Use more strlcpy() in two-phase transaction code
In-Reply-To: <E1wordv-00000000jAh-3jwy@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox