From 3e1e277f34e3d8a2bfd7df06be4e56683fab6199 Mon Sep 17 00:00:00 2001 From: Mario Gonzalez Date: Thu, 2 Jul 2026 23:30:34 -0400 Subject: [PATCH v1] Replace of strncpy on xactdesc.c ParsePrepareRecord function parses data from a xl_xact_prepare struct. During its execution, it uses strncpy() to copy some data over. This call can be replaced by strlcpy() from src/port/. Despite the space in memory used as a destination is zero'ed beforehand using the memset below, the rest of functions are already using strlcpy: memset(parsed, 0, sizeof(*parsed)); It seems like accidentally 'n' was typed when 'l' was supposed to be used. The change with strncpy was introduced in 1eb6d6527aae in twophase.c and then moved to xaxtdesc.c in 7b8a899bdeb. --- src/backend/access/rmgrdesc/xactdesc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/access/rmgrdesc/xactdesc.c b/src/backend/access/rmgrdesc/xactdesc.c index 4f53d3035cc..0f466a4c27c 100644 --- a/src/backend/access/rmgrdesc/xactdesc.c +++ b/src/backend/access/rmgrdesc/xactdesc.c @@ -256,7 +256,7 @@ ParsePrepareRecord(uint8 info, xl_xact_prepare *xlrec, xl_xact_parsed_prepare *p parsed->nabortstats = xlrec->nabortstats; parsed->nmsgs = xlrec->ninvalmsgs; - strncpy(parsed->twophase_gid, bufptr, xlrec->gidlen); + strlcpy(parsed->twophase_gid, bufptr, sizeof(parsed->twophase_gid)); bufptr += MAXALIGN(xlrec->gidlen); parsed->subxacts = (TransactionId *) bufptr; -- 2.47.3