aboutsummaryrefslogtreecommitdiff
path: root/src/bin/pg_dump/pg_backup_custom.c
diff options
context:
space:
mode:
authorStephen Frost <sfrost@snowman.net>2014-02-08 21:25:47 -0500
committerStephen Frost <sfrost@snowman.net>2014-02-08 21:25:47 -0500
commitcfa1b4a711dd03f824a9c3ab50911e61419d1eeb (patch)
treeaf9d3c16f8c15ce562e09a9c97bfe19baf9395b0 /src/bin/pg_dump/pg_backup_custom.c
parent66c04c981dfe7c1d1e633dddcecf01982d0bde65 (diff)
downloadpostgresql-cfa1b4a711dd03f824a9c3ab50911e61419d1eeb.tar.gz
postgresql-cfa1b4a711dd03f824a9c3ab50911e61419d1eeb.zip
Minor pg_dump improvements
Improve pg_dump by checking results on various fgetc() calls which previously were unchecked, ditto for ftello. Also clean up a couple of very minor memory leaks by waiting to allocate structures until after the initial check(s). Issues spotted by Coverity.
Diffstat (limited to 'src/bin/pg_dump/pg_backup_custom.c')
-rw-r--r--src/bin/pg_dump/pg_backup_custom.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/bin/pg_dump/pg_backup_custom.c b/src/bin/pg_dump/pg_backup_custom.c
index 263bcd3c532..a15254a118e 100644
--- a/src/bin/pg_dump/pg_backup_custom.c
+++ b/src/bin/pg_dump/pg_backup_custom.c
@@ -708,6 +708,9 @@ _CloseArchive(ArchiveHandle *AH)
{
WriteHead(AH);
tpos = ftello(AH->FH);
+ if (tpos < 0 || errno)
+ exit_horribly(modulename, "could not determine seek position in archive file: %s\n",
+ strerror(errno));
WriteToc(AH);
ctx->dataStart = _getFilePos(AH, ctx);
WriteDataChunks(AH, NULL);
@@ -756,7 +759,7 @@ _ReopenArchive(ArchiveHandle *AH)
errno = 0;
tpos = ftello(AH->FH);
- if (errno)
+ if (tpos < 0 || errno)
exit_horribly(modulename, "could not determine seek position in archive file: %s\n",
strerror(errno));