Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit821386a

Browse files
committed
Fix use of already freed memory when dumping a database's security label.
pg_dump.c:dumDatabase() called ArchiveEntry() with the results of a aquery that was PQclear()ed a couple lines earlier.Backpatch to 9.2 where security labels for shared objects whereintroduced.
1 parentc8ef5b1 commit821386a

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

‎src/bin/pg_dump/pg_dump.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2112,25 +2112,29 @@ dumpDatabase(Archive *fout)
21122112
dbCatId,0,dbDumpId);
21132113
}
21142114

2115-
PQclear(res);
2116-
21172115
/* Dump shared security label. */
21182116
if (!no_security_labels&&fout->remoteVersion >=90200)
21192117
{
2120-
PQExpBufferseclabelQry=createPQExpBuffer();
2118+
PGresult*shres;
2119+
PQExpBufferseclabelQry;
2120+
2121+
seclabelQry=createPQExpBuffer();
21212122

21222123
buildShSecLabelQuery(conn,"pg_database",dbCatId.oid,seclabelQry);
2123-
res=ExecuteSqlQuery(fout,seclabelQry->data,PGRES_TUPLES_OK);
2124+
shres=ExecuteSqlQuery(fout,seclabelQry->data,PGRES_TUPLES_OK);
21242125
resetPQExpBuffer(seclabelQry);
2125-
emitShSecLabels(conn,res,seclabelQry,"DATABASE",datname);
2126+
emitShSecLabels(conn,shres,seclabelQry,"DATABASE",datname);
21262127
if (strlen(seclabelQry->data))
21272128
ArchiveEntry(fout,dbCatId,createDumpId(),datname,NULL,NULL,
21282129
dba, false,"SECURITY LABEL",SECTION_NONE,
21292130
seclabelQry->data,"",NULL,
21302131
&dbDumpId,1,NULL,NULL);
21312132
destroyPQExpBuffer(seclabelQry);
2133+
PQclear(shres);
21322134
}
21332135

2136+
PQclear(res);
2137+
21342138
destroyPQExpBuffer(dbQry);
21352139
destroyPQExpBuffer(delQry);
21362140
destroyPQExpBuffer(creaQry);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp