]> granicus.if.org Git - postgresql/commitdiff
Fix off-by-one bug in XactLogCommitRecord
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Fri, 15 Jun 2018 19:00:41 +0000 (15:00 -0400)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Fri, 15 Jun 2018 19:00:41 +0000 (15:00 -0400)
Commit 1eb6d6527aae introduced zeroed alignment bytes in the GID field
of commit/abort WAL records.  Fixup commit cf5a1890592b later changed
that representation into a regular cstring with a single terminating
zero byte, but it also introduced an off-by-one mistake.  Fix that.

Author: Nikhil Sontakke
Reported-by: Nikhil Sontakke
Discussion: https://postgr.es/m/CAMGcDxey6dG1DP34_tJMoWPcp5sPJUAL4K5CayUUXLQSx2GQpA@mail.gmail.com

src/backend/access/transam/xact.c

index f4e5ea84b996d175da06f4ea0fa2cf6c4026737f..b51eeb087e8f404853a19b502e0ad06ff182172f 100644 (file)
@@ -5365,7 +5365,7 @@ XactLogCommitRecord(TimestampTz commit_time,
        {
                XLogRegisterData((char *) (&xl_twophase), sizeof(xl_xact_twophase));
                if (xl_xinfo.xinfo & XACT_XINFO_HAS_GID)
-                       XLogRegisterData((char *) twophase_gid, strlen(twophase_gid));
+                       XLogRegisterData((char *) twophase_gid, strlen(twophase_gid) + 1);
        }
 
        if (xl_xinfo.xinfo & XACT_XINFO_HAS_ORIGIN)