Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit99d334a

Browse files
committed
Fix edge-case for xl_tot_len broken bybae868c.
bae868c removed a check that was still needed. If you had anxl_tot_len at the end of a page that was too small for a record header,but not big enough to span onto the next page, we'd immediately performthe CRC check using a bogus large length. Because of arbitrary codingdifferences between the CRC implementations on different platforms,nothing very bad happened on common modern systems. On systems usingthe _sb8.c fallback we could segfault.Restore that check, add a new assertion and supply a test for that case.Back-patch to 12, likebae868c.Tested-by: Tom Lane <tgl@sss.pgh.pa.us>Tested-by: Alexander Lakhin <exclusion@gmail.com>Discussion:https://postgr.es/m/CA%2BhUKGLCkTT7zYjzOxuLGahBdQ%3DMcF%3Dz5ZvrjSOnW4EDhVjT-g%40mail.gmail.com
1 parent9dc3c54 commit99d334a

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

‎src/backend/access/transam/xlogreader.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,15 @@ XLogDecodeNextRecord(XLogReaderState *state, bool nonblocking)
651651
}
652652
else
653653
{
654+
/* There may be no next page if it's too small. */
655+
if (total_len<SizeOfXLogRecord)
656+
{
657+
report_invalid_record(state,
658+
"invalid record length at %X/%X: wanted %u, got %u",
659+
LSN_FORMAT_ARGS(RecPtr),
660+
(uint32)SizeOfXLogRecord,total_len);
661+
gotoerr;
662+
}
654663
/* We'll validate the header once we have the next page. */
655664
gotheader= false;
656665
}
@@ -1188,6 +1197,8 @@ ValidXLogRecord(XLogReaderState *state, XLogRecord *record, XLogRecPtr recptr)
11881197
{
11891198
pg_crc32ccrc;
11901199

1200+
Assert(record->xl_tot_len >=SizeOfXLogRecord);
1201+
11911202
/* Calculate the CRC */
11921203
INIT_CRC32C(crc);
11931204
COMP_CRC32C(crc, ((char*)record)+SizeOfXLogRecord,record->xl_tot_len-SizeOfXLogRecord);

‎src/test/recovery/t/039_end_of_wal.pl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,19 @@ sub advance_to_record_splitting_zone
281281
$log_size),
282282
"xl_tot_len short");
283283

284+
# xl_tot_len in final position, not big enough to span into a new page but
285+
# also not eligible for regular record header validation
286+
emit_message($node, 0);
287+
$end_lsn = advance_to_record_splitting_zone($node);
288+
$node->stop('immediate');
289+
write_wal($node,$TLI,$end_lsn, build_record_header(1));
290+
$log_size =-s$node->logfile;
291+
$node->start;
292+
ok($node->log_contains(
293+
"invalid record length at .*: wanted 24, got 1",$log_size
294+
),
295+
"xl_tot_len short at end-of-page");
296+
284297
# Need more pages, but xl_prev check fails first.
285298
emit_message($node, 0);
286299
$end_lsn = advance_out_of_record_splitting_zone($node);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp