Content-Length: 282388 | pFad | http://github.com/postgrespro/postgres_cluster/commit/d74ecbc8d85eb7a2aa1d5516c5c38d6ab0cbbd82

9C Protect against NULL-dereference in pg_dump · postgrespro/postgres_cluster@d74ecbc · GitHub
Skip to content

Commit d74ecbc

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 c52d37c commit d74ecbc

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
@@ -5643,6 +5643,9 @@ getOwnedSeqs(Archive *fout, TableInfo tblinfo[], int numTables)
56435643
continue; /* not an owned sequence */
56445644

56455645
owning_tab = findTableByOid(seqinfo->owning_tab);
5646+
if (owning_tab == NULL)
5647+
exit_horribly(NULL, "failed sanity check, parent table OID %u of sequence OID %u not found\n",
5648+
seqinfo->owning_tab, seqinfo->dobj.catId.oid);
56465649

56475650
/*
56485651
* We need to dump the components that are being dumped for the table
@@ -15583,7 +15586,11 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
1558315586
{
1558415587
TableInfo *owning_tab = findTableByOid(tbinfo->owning_tab);
1558515588

15586-
if (owning_tab && owning_tab->dobj.dump & DUMP_COMPONENT_DEFINITION)
15589+
if (owning_tab == NULL)
15590+
exit_horribly(NULL, "failed sanity check, parent table OID %u of sequence OID %u not found\n",
15591+
tbinfo->owning_tab, tbinfo->dobj.catId.oid);
15592+
15593+
if (owning_tab->dobj.dump & DUMP_COMPONENT_DEFINITION)
1558715594
{
1558815595
resetPQExpBuffer(query);
1558915596
appendPQExpBuffer(query, "ALTER SEQUENCE %s",

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres_cluster/commit/d74ecbc8d85eb7a2aa1d5516c5c38d6ab0cbbd82

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy