diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2007-08-06 01:38:32 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2007-08-06 01:38:32 +0000 |
commit | 6d1607dc3f83d1de9b4daeba2f0622e29cafc524 (patch) | |
tree | 16d67e7e8db7ebdd36dd1ae15e92b4b5f390fc92 /src/bin/pg_dump/pg_backup_custom.c | |
parent | f99e72fa51d1a0de26dff3878832c9e2ed3f4f12 (diff) |
Fix pg_restore to guard against unexpected EOF while reading an archive file.
Per report and partial patch from Chad Wagner.
Diffstat (limited to 'src/bin/pg_dump/pg_backup_custom.c')
-rw-r--r-- | src/bin/pg_dump/pg_backup_custom.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/bin/pg_dump/pg_backup_custom.c b/src/bin/pg_dump/pg_backup_custom.c index 3edbb8f5c0a..bfa4eaf02f4 100644 --- a/src/bin/pg_dump/pg_backup_custom.c +++ b/src/bin/pg_dump/pg_backup_custom.c @@ -19,7 +19,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.33 2005/10/15 02:49:38 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.33.2.1 2007/08/06 01:38:32 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -703,7 +703,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) @@ -711,9 +711,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; } |