Skip to content

Commit a08dc71

Browse files
committed
Fix for checksum validation patch
Reorder the check for non-BLCKSZ size reads to make sure we don't abort sending the file in this case. Missed in the previous commit.
1 parent 4eb77d5 commit a08dc71

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

src/backend/replication/basebackup.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,26 +1410,26 @@ sendFile(const char *readfilename, const char *tarfilename, struct stat *statbuf
14101410

14111411
while ((cnt = fread(buf, 1, Min(sizeof(buf), statbuf->st_size - len), fp)) > 0)
14121412
{
1413-
if (verify_checksum)
1413+
/*
1414+
* The checksums are verified at block level, so we iterate over
1415+
* the buffer in chunks of BLCKSZ, after making sure that
1416+
* TAR_SEND_SIZE/buf is divisible by BLCKSZ and we read a multiple
1417+
* of BLCKSZ bytes.
1418+
*/
1419+
Assert(TAR_SEND_SIZE % BLCKSZ == 0);
1420+
1421+
if (verify_checksum && (cnt % BLCKSZ != 0))
14141422
{
1415-
/*
1416-
* The checksums are verified at block level, so we iterate over
1417-
* the buffer in chunks of BLCKSZ, after making sure that
1418-
* TAR_SEND_SIZE/buf is divisible by BLCKSZ and we read a multiple
1419-
* of BLCKSZ bytes.
1420-
*/
1421-
Assert(TAR_SEND_SIZE % BLCKSZ == 0);
1423+
ereport(WARNING,
1424+
(errmsg("cannot verify checksum in file \"%s\", block "
1425+
"%d: read buffer size %d and page size %d "
1426+
"differ",
1427+
readfilename, blkno, (int) cnt, BLCKSZ)));
1428+
verify_checksum = false;
1429+
}
14221430

1423-
if (cnt % BLCKSZ != 0)
1424-
{
1425-
ereport(WARNING,
1426-
(errmsg("cannot verify checksum in file \"%s\", block "
1427-
"%d: read buffer size %d and page size %d "
1428-
"differ",
1429-
readfilename, blkno, (int) cnt, BLCKSZ)));
1430-
verify_checksum = false;
1431-
continue;
1432-
}
1431+
if (verify_checksum)
1432+
{
14331433
for (i = 0; i < cnt / BLCKSZ; i++)
14341434
{
14351435
page = buf + BLCKSZ * i;

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