Skip to content

Commit 2848c30

Browse files
committed
Fix unligned access in parse commit record
1 parent cacdcc5 commit 2848c30

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

src/backend/access/rmgrdesc/xactdesc.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,8 @@ ParseCommitRecord(uint8 info, xl_xact_commit *xlrec, xl_xact_parsed_commit *pars
7979
uint8 gidlen = xl_twophase->gidlen;
8080

8181
parsed->twophase_xid = xl_twophase->xid;
82-
data += MAXALIGN(MinSizeOfXactTwophase);
83-
84-
strcpy(parsed->twophase_gid, data);
85-
data += MAXALIGN(gidlen);
82+
strcpy(parsed->twophase_gid, xl_twophase->gid);
83+
data += INTALIGN(MinSizeOfXactTwophase + gidlen);
8684
}
8785

8886
if (parsed->xinfo & XACT_XINFO_HAS_RELFILENODES)
@@ -169,10 +167,8 @@ ParseAbortRecord(uint8 info, xl_xact_abort *xlrec, xl_xact_parsed_abort *parsed)
169167
uint8 gidlen = xl_twophase->gidlen;
170168

171169
parsed->twophase_xid = xl_twophase->xid;
172-
data += MAXALIGN(MinSizeOfXactTwophase);
173-
174-
strcpy(parsed->twophase_gid, data);
175-
data += MAXALIGN(gidlen);
170+
strcpy(parsed->twophase_gid, xl_twophase->gid);
171+
data += INTALIGN(MinSizeOfXactTwophase + gidlen);
176172
}
177173

178174
if (parsed->xinfo & XACT_XINFO_HAS_ORIGIN)

src/backend/access/transam/xact.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5515,7 +5515,7 @@ XactLogCommitRecord(TimestampTz commit_time,
55155515
if (xl_xinfo.xinfo & XACT_XINFO_HAS_TWOPHASE)
55165516
{
55175517
XLogRegisterData((char *) (&xl_twophase), MinSizeOfXactTwophase);
5518-
XLogRegisterData((char *) twophase_gid, xl_twophase.gidlen);
5518+
XLogRegisterData((char *) twophase_gid, INTALIGN(xl_twophase.gidlen));
55195519
}
55205520

55215521
if (xl_xinfo.xinfo & XACT_XINFO_HAS_RELFILENODES)
@@ -5639,7 +5639,7 @@ XactLogAbortRecord(TimestampTz abort_time,
56395639
if (xl_xinfo.xinfo & XACT_XINFO_HAS_TWOPHASE)
56405640
{
56415641
XLogRegisterData((char *) (&xl_twophase), MinSizeOfXactTwophase);
5642-
XLogRegisterData((char *) twophase_gid, xl_twophase.gidlen);
5642+
XLogRegisterData((char *) twophase_gid, INTALIGN(xl_twophase.gidlen));
56435643
}
56445644

56455645
if (xl_xinfo.xinfo & XACT_XINFO_HAS_ORIGIN)

src/include/access/xact.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ typedef struct xl_xact_twophase
233233
* Gid and gidlen will be set only with wal_level=logical.
234234
* See details in XactLogCommitRecord().
235235
*/
236-
uint8 gidlen;
236+
int gidlen;
237237
char gid[GIDSIZE];
238238
} xl_xact_twophase;
239239
#define MinSizeOfXactTwophase offsetof(xl_xact_twophase, gid)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy