aboutsummaryrefslogtreecommitdiff
path: root/src/bin/pg_dump/pg_backup_archiver.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/pg_dump/pg_backup_archiver.c')
-rw-r--r--src/bin/pg_dump/pg_backup_archiver.c12
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 1abd3b19912..49f5087e6a6 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.117.2.4 2006/05/24 21:20:24 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.117.2.5 2007/08/06 01:38:32 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1398,7 +1398,7 @@ ReadStr(ArchiveHandle *AH)
int l;
l = ReadInt(AH);
- if (l == -1)
+ if (l < 0)
buf = NULL;
else
{
@@ -1406,7 +1406,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';
}
@@ -2547,8 +2549,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");