From: | Oliver Elphick <olly(at)lfix(dot)co(dot)uk> |
---|---|
To: | PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org> |
Subject: | Fix segfault in pg_restore |
Date: | 2003-01-23 18:28:50 |
Message-ID: | 1043346530.31735.445.camel@linda.lfix.co.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-patches |
In pg_restore, die_horribly() is sometimes called with AH a null
pointer. If that happens, there is currently a segfault because the
code attempts to dereference an element in the AH structure
unconditionally:
$ pg_restore -Ft nonexistent
pg_restore: [tar archiver] could not open TOC file for input: No such
file or directory
Segmentation fault
This patch makes it dereference the structure only if AH is set.
Index: src/bin/pg_dump/pg_backup_archiver.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/bin/pg_dump/pg_backup_archiver.c,v
retrieving revision 1.65
diff -u -r1.65 pg_backup_archiver.c
--- src/bin/pg_dump/pg_backup_archiver.c 2003/01/13 04:28:55 1.65
+++ src/bin/pg_dump/pg_backup_archiver.c 2003/01/23 13:39:16
@@ -1379,14 +1379,15 @@
_die_horribly(ArchiveHandle *AH, const char *modulename, const char *fmt, va_list ap)
{
_write_msg(modulename, fmt, ap);
- if (AH->public.verbose)
- write_msg(NULL, "*** aborted because of error\n");
- if (AH)
+ if (AH) {
+ if (AH->public.verbose)
+ write_msg(NULL, "*** aborted because of error\n");
if (AH->connection)
PQfinish(AH->connection);
- if (AH->blobConnection)
- PQfinish(AH->blobConnection);
+ if (AH->blobConnection)
+ PQfinish(AH->blobConnection);
+ }
exit(1);
}
--
Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
LFIX Limited
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Eisentraut | 2003-01-23 18:31:41 | Re: SEQUENCEs and NO MAXVALUE NO MINVALUE |
Previous Message | Kris Jurka | 2003-01-23 18:15:53 | Re: question about rollback and SQLException |