Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8b1bf31

Browse files
committed
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 f9e439b 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.
1 parent 4103a2f commit 8b1bf31

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/bin/pg_dump/pg_dump.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6089,6 +6089,9 @@ getOwnedSeqs(Archive *fout, TableInfo tblinfo[], int numTables)
60896089
continue; /* not an owned sequence */
60906090

60916091
owning_tab = findTableByOid(seqinfo->owning_tab);
6092+
if (owning_tab == NULL)
6093+
exit_horribly(NULL, "failed sanity check, parent table OID %u of sequence OID %u not found\n",
6094+
seqinfo->owning_tab, seqinfo->dobj.catId.oid);
60926095

60936096
/*
60946097
* We need to dump the components that are being dumped for the table
@@ -16537,7 +16540,11 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
1653716540
{
1653816541
TableInfo *owning_tab = findTableByOid(tbinfo->owning_tab);
1653916542

16540-
if (owning_tab && owning_tab->dobj.dump & DUMP_COMPONENT_DEFINITION)
16543+
if (owning_tab == NULL)
16544+
exit_horribly(NULL, "failed sanity check, parent table OID %u of sequence OID %u not found\n",
16545+
tbinfo->owning_tab, tbinfo->dobj.catId.oid);
16546+
16547+
if (owning_tab->dobj.dump & DUMP_COMPONENT_DEFINITION)
1654116548
{
1654216549
resetPQExpBuffer(query);
1654316550
appendPQExpBuffer(query, "ALTER SEQUENCE %s",

0 commit comments

Comments
 (0)