diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2007-08-06 01:38:57 +0000 | 
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2007-08-06 01:38:57 +0000 | 
| commit | 99fa5f458c210c05dd1bb8fdf603f0acc22a0a12 (patch) | |
| tree | b9fc6ba4e3913fbeb62b2177d63157e3fc77c8b4 /src/bin/pg_dump/pg_backup_custom.c | |
| parent | 681690f4e374d88877ea2f4de1baa04f780abd8e (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 c2fcef7536e..a15a04aa3ab 100644 --- a/src/bin/pg_dump/pg_backup_custom.c +++ b/src/bin/pg_dump/pg_backup_custom.c @@ -19,7 +19,7 @@   *   *   * IDENTIFICATION - *		$Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.23 2002/10/25 01:33:17 momjian Exp $ + *		$Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.23.2.1 2007/08/06 01:38:57 tgl Exp $   *   *-------------------------------------------------------------------------   */ @@ -713,7 +713,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) @@ -721,9 +721,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;  }  | 
