diff options
Diffstat (limited to 'src/bin/pg_dump/pg_backup_archiver.c')
-rw-r--r-- | src/bin/pg_dump/pg_backup_archiver.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c index 981168bfa7c..c0e192e859b 100644 --- a/src/bin/pg_dump/pg_backup_archiver.c +++ b/src/bin/pg_dump/pg_backup_archiver.c @@ -15,7 +15,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.144 2007/03/26 16:58:39 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.145 2007/08/06 01:38:14 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1472,7 +1472,7 @@ ReadStr(ArchiveHandle *AH) int l; l = ReadInt(AH); - if (l == -1) + if (l < 0) buf = NULL; else { @@ -1480,7 +1480,9 @@ ReadStr(ArchiveHandle *AH) if (!buf) die_horribly(AH, modulename, "out of memory\n"); - (*AH->ReadBufPtr) (AH, (void *) buf, l); + if ((*AH->ReadBufPtr) (AH, (void *) buf, l) != l) + die_horribly(AH, modulename, "unexpected end of file\n"); + buf[l] = '\0'; } @@ -2675,8 +2677,8 @@ ReadHead(ArchiveHandle *AH) /* If we haven't already read the header... */ if (!AH->readHeader) { - - (*AH->ReadBufPtr) (AH, tmpMag, 5); + if ((*AH->ReadBufPtr) (AH, tmpMag, 5) != 5) + die_horribly(AH, modulename, "unexpected end of file\n"); if (strncmp(tmpMag, "PGDMP", 5) != 0) die_horribly(AH, modulename, "did not find magic string in file header\n"); |