diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2007-08-06 01:38:24 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2007-08-06 01:38:24 +0000 |
commit | f614a2b50842c5ced90cd5c5af802684028510a9 (patch) | |
tree | f65d753b8d32c3080d6bcc160be4cd133a40a35e /src/bin/pg_dump/pg_backup_custom.c | |
parent | fffafc5dca40ceca6912facca47c2e78e7e7c7e6 (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 e847653f88e..50ed0159d51 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.36.2.1 2007/02/19 15:05:21 mha Exp $ + * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.36.2.2 2007/08/06 01:38:24 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; } |