aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStephen Frost <sfrost@snowman.net>2017-01-06 15:27:47 -0500
committerStephen Frost <sfrost@snowman.net>2017-01-06 15:27:47 -0500
commitd74ecbc8d85eb7a2aa1d5516c5c38d6ab0cbbd82 (patch)
tree3f200689ce11516630951e9748f2f84087b0d5e6 /src
parentc52d37c8b3674f1ca9ead297480ade0ac9c54174 (diff)
downloadpostgresql-d74ecbc8d85eb7a2aa1d5516c5c38d6ab0cbbd82.tar.gz
postgresql-d74ecbc8d85eb7a2aa1d5516c5c38d6ab0cbbd82.zip
Protect against NULL-dereference in pg_dump
findTableByOid() is allowed to return NULL and we should therefore be checking for that case. getOwnedSeqs() and dumpSequence() shouldn't ever actually see this happen, but given odd circumstances it might and commit f9e439b1 probably shouldn't have removed that check. Pointed out by Coverity. Initial patch from Michael Paquier. Back-patch to 9.6, where that commit had removed the check.
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_dump/pg_dump.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 6a53a051294..c1084aaf8db 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -5643,6 +5643,9 @@ getOwnedSeqs(Archive *fout, TableInfo tblinfo[], int numTables)
continue; /* not an owned sequence */
owning_tab = findTableByOid(seqinfo->owning_tab);
+ if (owning_tab == NULL)
+ exit_horribly(NULL, "failed sanity check, parent table OID %u of sequence OID %u not found\n",
+ seqinfo->owning_tab, seqinfo->dobj.catId.oid);
/*
* We need to dump the components that are being dumped for the table
@@ -15583,7 +15586,11 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
{
TableInfo *owning_tab = findTableByOid(tbinfo->owning_tab);
- if (owning_tab && owning_tab->dobj.dump & DUMP_COMPONENT_DEFINITION)
+ if (owning_tab == NULL)
+ exit_horribly(NULL, "failed sanity check, parent table OID %u of sequence OID %u not found\n",
+ tbinfo->owning_tab, tbinfo->dobj.catId.oid);
+
+ if (owning_tab->dobj.dump & DUMP_COMPONENT_DEFINITION)
{
resetPQExpBuffer(query);
appendPQExpBuffer(query, "ALTER SEQUENCE %s",