mirror of
https://github.com/postgres/postgres.git
synced 2025-06-06 00:02:36 -04:00
Fix aboriginal bug in _tarAddFile(): when complaining that the amount of data
read from the temp file didn't match the file length reported by ftello(), the wrong variable's value was printed, and so the message made no sense. Clean up a couple other coding infelicities while at it.
This commit is contained in:
parent
2169ad2208
commit
c06e5bb7bb
@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.49.2.4 2007/08/06 01:38:32 tgl Exp $
|
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.49.2.5 2007/08/29 16:31:51 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -1059,6 +1059,7 @@ _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th)
|
|||||||
*/
|
*/
|
||||||
fseeko(tmp, 0, SEEK_END);
|
fseeko(tmp, 0, SEEK_END);
|
||||||
th->fileLen = ftello(tmp);
|
th->fileLen = ftello(tmp);
|
||||||
|
fseeko(tmp, 0, SEEK_SET);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Some compilers with throw a warning knowing this test can never be true
|
* Some compilers with throw a warning knowing this test can never be true
|
||||||
@ -1066,13 +1067,12 @@ _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th)
|
|||||||
*/
|
*/
|
||||||
if (th->fileLen > MAX_TAR_MEMBER_FILELEN)
|
if (th->fileLen > MAX_TAR_MEMBER_FILELEN)
|
||||||
die_horribly(AH, modulename, "archive member too large for tar format\n");
|
die_horribly(AH, modulename, "archive member too large for tar format\n");
|
||||||
fseeko(tmp, 0, SEEK_SET);
|
|
||||||
|
|
||||||
_tarWriteHeader(th);
|
_tarWriteHeader(th);
|
||||||
|
|
||||||
while ((cnt = fread(&buf[0], 1, 32767, tmp)) > 0)
|
while ((cnt = fread(buf, 1, sizeof(buf), tmp)) > 0)
|
||||||
{
|
{
|
||||||
res = fwrite(&buf[0], 1, cnt, th->tarFH);
|
res = fwrite(buf, 1, cnt, th->tarFH);
|
||||||
if (res != cnt)
|
if (res != cnt)
|
||||||
die_horribly(AH, modulename,
|
die_horribly(AH, modulename,
|
||||||
"write error appending to tar archive (wrote %lu, attempted %lu)\n",
|
"write error appending to tar archive (wrote %lu, attempted %lu)\n",
|
||||||
@ -1081,15 +1081,16 @@ _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fclose(tmp) != 0) /* This *should* delete it... */
|
if (fclose(tmp) != 0) /* This *should* delete it... */
|
||||||
die_horribly(AH, modulename, "could not close tar member: %s\n", strerror(errno));
|
die_horribly(AH, modulename, "could not close tar member: %s\n",
|
||||||
|
strerror(errno));
|
||||||
|
|
||||||
if (len != th->fileLen)
|
if (len != th->fileLen)
|
||||||
{
|
{
|
||||||
char buf1[100],
|
char buf1[32],
|
||||||
buf2[100];
|
buf2[32];
|
||||||
|
|
||||||
snprintf(buf1, sizeof(buf1), INT64_FORMAT, (int64) len);
|
snprintf(buf1, sizeof(buf1), INT64_FORMAT, (int64) len);
|
||||||
snprintf(buf2, sizeof(buf2), INT64_FORMAT, (int64) th->pos);
|
snprintf(buf2, sizeof(buf2), INT64_FORMAT, (int64) th->fileLen);
|
||||||
die_horribly(AH, modulename, "actual file length (%s) does not match expected (%s)\n",
|
die_horribly(AH, modulename, "actual file length (%s) does not match expected (%s)\n",
|
||||||
buf1, buf2);
|
buf1, buf2);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user