mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-10-03 15:16:57 +02:00
Fix use of already freed memory when dumping a database's security label.
pg_dump.c:dumDatabase() called ArchiveEntry() with the results of a a query that was PQclear()ed a couple lines earlier. Backpatch to 9.2 where security labels for shared objects where introduced.
This commit is contained in:
parent
ff44fba46c
commit
525b84c576
@ -2476,25 +2476,29 @@ dumpDatabase(Archive *fout, DumpOptions *dopt)
|
|||||||
dbCatId, 0, dbDumpId);
|
dbCatId, 0, dbDumpId);
|
||||||
}
|
}
|
||||||
|
|
||||||
PQclear(res);
|
|
||||||
|
|
||||||
/* Dump shared security label. */
|
/* Dump shared security label. */
|
||||||
if (!dopt->no_security_labels && fout->remoteVersion >= 90200)
|
if (!dopt->no_security_labels && fout->remoteVersion >= 90200)
|
||||||
{
|
{
|
||||||
PQExpBuffer seclabelQry = createPQExpBuffer();
|
PGresult *shres;
|
||||||
|
PQExpBuffer seclabelQry;
|
||||||
|
|
||||||
|
seclabelQry = createPQExpBuffer();
|
||||||
|
|
||||||
buildShSecLabelQuery(conn, "pg_database", dbCatId.oid, seclabelQry);
|
buildShSecLabelQuery(conn, "pg_database", dbCatId.oid, seclabelQry);
|
||||||
res = ExecuteSqlQuery(fout, seclabelQry->data, PGRES_TUPLES_OK);
|
shres = ExecuteSqlQuery(fout, seclabelQry->data, PGRES_TUPLES_OK);
|
||||||
resetPQExpBuffer(seclabelQry);
|
resetPQExpBuffer(seclabelQry);
|
||||||
emitShSecLabels(conn, res, seclabelQry, "DATABASE", datname);
|
emitShSecLabels(conn, shres, seclabelQry, "DATABASE", datname);
|
||||||
if (strlen(seclabelQry->data))
|
if (strlen(seclabelQry->data))
|
||||||
ArchiveEntry(fout, dbCatId, createDumpId(), datname, NULL, NULL,
|
ArchiveEntry(fout, dbCatId, createDumpId(), datname, NULL, NULL,
|
||||||
dba, false, "SECURITY LABEL", SECTION_NONE,
|
dba, false, "SECURITY LABEL", SECTION_NONE,
|
||||||
seclabelQry->data, "", NULL,
|
seclabelQry->data, "", NULL,
|
||||||
&dbDumpId, 1, NULL, NULL);
|
&dbDumpId, 1, NULL, NULL);
|
||||||
destroyPQExpBuffer(seclabelQry);
|
destroyPQExpBuffer(seclabelQry);
|
||||||
|
PQclear(shres);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PQclear(res);
|
||||||
|
|
||||||
destroyPQExpBuffer(dbQry);
|
destroyPQExpBuffer(dbQry);
|
||||||
destroyPQExpBuffer(delQry);
|
destroyPQExpBuffer(delQry);
|
||||||
destroyPQExpBuffer(creaQry);
|
destroyPQExpBuffer(creaQry);
|
||||||
|
Loading…
Reference in New Issue
Block a user