Skip to content

Commit 15fe6af

Browse files
committed
fix len calculation in 2pc file header
1 parent 567f98f commit 15fe6af

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/backend/access/transam/twophase.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,7 +1218,6 @@ ReadTwoPhaseFile(TransactionId xid, bool give_warnings)
12181218
if (crc_offset != MAXALIGN(crc_offset))
12191219
{
12201220
CloseTransientFile(fd);
1221-
fprintf(stderr, "wrong crc offset in two-phase file \"%s\"\n", path);
12221221
return NULL;
12231222
}
12241223

@@ -1245,7 +1244,6 @@ ReadTwoPhaseFile(TransactionId xid, bool give_warnings)
12451244
if (hdr->magic != TWOPHASE_MAGIC || hdr->total_len != stat.st_size)
12461245
{
12471246
pfree(buf);
1248-
fprintf(stderr, "muggle two-phase file \"%s\": no magic\n", path);
12491247
return NULL;
12501248
}
12511249

@@ -1622,6 +1620,10 @@ RecreateTwoPhaseFile(TransactionId xid, void *content, int len)
16221620
pg_crc32c statefile_crc;
16231621
int fd;
16241622

1623+
/* Crutch to fix crc and len check on 2pc file reading */
1624+
Assert( ((TwoPhaseFileHeader *) content)->total_len - sizeof(pg_crc32c) <= len);
1625+
len = ((TwoPhaseFileHeader *) content)->total_len - sizeof(pg_crc32c);
1626+
16251627
/* Recompute CRC */
16261628
INIT_CRC32C(statefile_crc);
16271629
COMP_CRC32C(statefile_crc, content, len);

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