mirror of
https://github.com/postgres/postgres.git
synced 2025-11-13 16:22:44 +03:00
Fix unaligned memory access in xlog parsing due to replication origin patch.
ParseCommitRecord() accessed xl_xact_origin directly. But the chunks in the commit record's data only have 4 byte alignment, whereas xl_xact_origin's members require 8 byte alignment on some platforms. Update comments to make not of that and copy the record to stack local storage before reading. With help from Stefan Kaltenbrunner in pinning down the buildfarm and verifying the fix.
This commit is contained in:
@@ -104,10 +104,13 @@ ParseCommitRecord(uint8 info, xl_xact_commit *xlrec, xl_xact_parsed_commit *pars
|
||||
|
||||
if (parsed->xinfo & XACT_XINFO_HAS_ORIGIN)
|
||||
{
|
||||
xl_xact_origin *xl_origin = (xl_xact_origin *) data;
|
||||
xl_xact_origin xl_origin;
|
||||
|
||||
parsed->origin_lsn = xl_origin->origin_lsn;
|
||||
parsed->origin_timestamp = xl_origin->origin_timestamp;
|
||||
/* we're only guaranteed 4 byte alignment, so copy onto stack */
|
||||
memcpy(&xl_origin, data, sizeof(xl_origin));
|
||||
|
||||
parsed->origin_lsn = xl_origin.origin_lsn;
|
||||
parsed->origin_timestamp = xl_origin.origin_timestamp;
|
||||
|
||||
data += sizeof(xl_xact_origin);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user