From 239c3ee41be3b7c621c446344d09e3affeb8cd59 Mon Sep 17 00:00:00 2001 From: Tomas Vondra Date: Tue, 16 Aug 2022 23:52:10 +0200 Subject: [PATCH] Fix assert in logicalmsg_desc The assert, introduced by 9f1cf97bb5, is intended to check if the prefix is terminated by a \0 byte, but it has two flaws. Firstly, prefix_size includes the \0 byte, so prefix[prefix_size] points to the byte after the null byte. Secondly, the check ensures the byte is not equal \0, while it should be checking the opposite. Backpatch-through: 14 Discussion: https://postgr.es/m/b99b6101-2f14-3796-3dfa-4a6cd7d4326d@enterprisedb.com --- src/backend/access/rmgrdesc/logicalmsgdesc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/access/rmgrdesc/logicalmsgdesc.c b/src/backend/access/rmgrdesc/logicalmsgdesc.c index d64ce2e7ef..dee440f7d9 100644 --- a/src/backend/access/rmgrdesc/logicalmsgdesc.c +++ b/src/backend/access/rmgrdesc/logicalmsgdesc.c @@ -28,7 +28,7 @@ logicalmsg_desc(StringInfo buf, XLogReaderState *record) char *message = xlrec->message + xlrec->prefix_size; char *sep = ""; - Assert(prefix[xlrec->prefix_size] != '\0'); + Assert(prefix[xlrec->prefix_size - 1] == '\0'); appendStringInfo(buf, "%s, prefix \"%s\"; payload (%zu bytes): ", xlrec->transactional ? "transactional" : "non-transactional",