From fcb9535e8a3576f6bfcc54bdc52c195d46f32b53 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 6 Aug 2007 01:38:15 +0000 Subject: Fix pg_restore to guard against unexpected EOF while reading an archive file. Per report and partial patch from Chad Wagner. --- src/bin/pg_dump/pg_backup_files.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/bin/pg_dump/pg_backup_files.c') diff --git a/src/bin/pg_dump/pg_backup_files.c b/src/bin/pg_dump/pg_backup_files.c index 2b292aa5792..6520ca227aa 100644 --- a/src/bin/pg_dump/pg_backup_files.c +++ b/src/bin/pg_dump/pg_backup_files.c @@ -20,7 +20,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.32 2007/03/18 16:50:44 neilc Exp $ + * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.33 2007/08/06 01:38:15 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -395,9 +395,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; } -- cgit v1.2.3