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

Commit509da59

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 parente32cb8d commit509da59

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
@@ -2428,25 +2428,29 @@ dumpDatabase(Archive *fout)
24282428
dbCatId,0,dbDumpId);
24292429
}
24302430

2431-
PQclear(res);
2432-
24332431
/* Dump shared security label. */
24342432
if (!no_security_labels&&fout->remoteVersion >=90200)
24352433
{
2436-
PQExpBufferseclabelQry=createPQExpBuffer();
2434+
PGresult*shres;
2435+
PQExpBufferseclabelQry;
2436+
2437+
seclabelQry=createPQExpBuffer();
24372438

24382439
buildShSecLabelQuery(conn,"pg_database",dbCatId.oid,seclabelQry);
2439-
res=ExecuteSqlQuery(fout,seclabelQry->data,PGRES_TUPLES_OK);
2440+
shres=ExecuteSqlQuery(fout,seclabelQry->data,PGRES_TUPLES_OK);
24402441
resetPQExpBuffer(seclabelQry);
2441-
emitShSecLabels(conn,res,seclabelQry,"DATABASE",datname);
2442+
emitShSecLabels(conn,shres,seclabelQry,"DATABASE",datname);
24422443
if (strlen(seclabelQry->data))
24432444
ArchiveEntry(fout,dbCatId,createDumpId(),datname,NULL,NULL,
24442445
dba, false,"SECURITY LABEL",SECTION_NONE,
24452446
seclabelQry->data,"",NULL,
24462447
&dbDumpId,1,NULL,NULL);
24472448
destroyPQExpBuffer(seclabelQry);
2449+
PQclear(shres);
24482450
}
24492451

2452+
PQclear(res);
2453+
24502454
destroyPQExpBuffer(dbQry);
24512455
destroyPQExpBuffer(delQry);
24522456
destroyPQExpBuffer(creaQry);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp