1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-02 09:02:37 +03:00

Fix pg_restore to guard against unexpected EOF while reading an archive file.

Per report and partial patch from Chad Wagner.
This commit is contained in:
Tom Lane
2007-08-06 01:38:15 +00:00
parent df9ea6a1f1
commit fcb9535e8a
4 changed files with 25 additions and 20 deletions

View File

@ -19,7 +19,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.38 2007/03/18 16:50:44 neilc Exp $
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.39 2007/08/06 01:38:14 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -712,7 +712,7 @@ _WriteByte(ArchiveHandle *AH, const int i)
*
* Called by the archiver to read bytes & integers from the archive.
* These routines are only used to read & write headers & TOC.
*
* EOF should be treated as a fatal error.
*/
static int
_ReadByte(ArchiveHandle *AH)
@ -720,9 +720,10 @@ _ReadByte(ArchiveHandle *AH)
lclContext *ctx = (lclContext *) AH->formatData;
int res;
res = fgetc(AH->FH);
if (res != EOF)
ctx->filePos += 1;
res = getc(AH->FH);
if (res == EOF)
die_horribly(AH, modulename, "unexpected end of file\n");
ctx->filePos += 1;
return res;
}