Commit a08dc711 authored by Magnus Hagander's avatar Magnus Hagander

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.
parent 4eb77d50
...@@ -1409,8 +1409,6 @@ sendFile(const char *readfilename, const char *tarfilename, struct stat *statbuf ...@@ -1409,8 +1409,6 @@ sendFile(const char *readfilename, const char *tarfilename, struct stat *statbuf
} }
while ((cnt = fread(buf, 1, Min(sizeof(buf), statbuf->st_size - len), fp)) > 0) while ((cnt = fread(buf, 1, Min(sizeof(buf), statbuf->st_size - len), fp)) > 0)
{
if (verify_checksum)
{ {
/* /*
* The checksums are verified at block level, so we iterate over * The checksums are verified at block level, so we iterate over
...@@ -1420,7 +1418,7 @@ sendFile(const char *readfilename, const char *tarfilename, struct stat *statbuf ...@@ -1420,7 +1418,7 @@ sendFile(const char *readfilename, const char *tarfilename, struct stat *statbuf
*/ */
Assert(TAR_SEND_SIZE % BLCKSZ == 0); Assert(TAR_SEND_SIZE % BLCKSZ == 0);
if (cnt % BLCKSZ != 0) if (verify_checksum && (cnt % BLCKSZ != 0))
{ {
ereport(WARNING, ereport(WARNING,
(errmsg("cannot verify checksum in file \"%s\", block " (errmsg("cannot verify checksum in file \"%s\", block "
...@@ -1428,8 +1426,10 @@ sendFile(const char *readfilename, const char *tarfilename, struct stat *statbuf ...@@ -1428,8 +1426,10 @@ sendFile(const char *readfilename, const char *tarfilename, struct stat *statbuf
"differ", "differ",
readfilename, blkno, (int) cnt, BLCKSZ))); readfilename, blkno, (int) cnt, BLCKSZ)));
verify_checksum = false; verify_checksum = false;
continue;
} }
if (verify_checksum)
{
for (i = 0; i < cnt / BLCKSZ; i++) for (i = 0; i < cnt / BLCKSZ; i++)
{ {
page = buf + BLCKSZ * i; page = buf + BLCKSZ * i;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment