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

Commit925b3aa

Browse files
committed
Clear padding of PgStat_HashKey when handling pgstats entries
PgStat_HashKey is currently initialized in a way that could result inrandom data if the structure has any padding bytes. The structurehas no padding bytes currently, fortunately, but it could become aproblem should the structure change at some point in the future.The code is changed to use some memset(0) so as any padding would behandled properly, as it would be surprising to see random failures inthe pgstats entry lookups. PgStat_HashKey is a structure internal topgstats, and an ABI change could be possible in the scope of a bug fix,so backpatch down to 15 where this has been introduced.Author: Bertrand DrouvotReviewed-by: Jelte Fennema-Nio, Michael PaquierDiscussion:https://postgr.es/m/Zyb7RW1y9dVfO0UH@ip-10-97-1-34.eu-west-3.compute.internalBackpatch-through: 15
1 parent5e08ac6 commit925b3aa

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

‎src/backend/utils/activity/pgstat.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,9 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, Oid objoid)
825825

826826
pgstat_prep_snapshot();
827827

828+
/* clear padding */
829+
memset(&key,0,sizeof(structPgStat_HashKey));
830+
828831
key.kind=kind;
829832
key.dboid=dboid;
830833
key.objoid=objoid;

‎src/backend/utils/activity/pgstat_shmem.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,11 +405,18 @@ PgStat_EntryRef *
405405
pgstat_get_entry_ref(PgStat_Kindkind,Oiddboid,Oidobjoid,boolcreate,
406406
bool*created_entry)
407407
{
408-
PgStat_HashKeykey= {.kind=kind,.dboid=dboid,.objoid=objoid};
408+
PgStat_HashKeykey;
409409
PgStatShared_HashEntry*shhashent;
410410
PgStatShared_Common*shheader=NULL;
411411
PgStat_EntryRef*entry_ref;
412412

413+
/* clear padding */
414+
memset(&key,0,sizeof(structPgStat_HashKey));
415+
416+
key.kind=kind;
417+
key.dboid=dboid;
418+
key.objoid=objoid;
419+
413420
/*
414421
* passing in created_entry only makes sense if we possibly could create
415422
* entry.
@@ -880,10 +887,17 @@ pgstat_drop_database_and_contents(Oid dboid)
880887
bool
881888
pgstat_drop_entry(PgStat_Kindkind,Oiddboid,Oidobjoid)
882889
{
883-
PgStat_HashKeykey= {.kind=kind,.dboid=dboid,.objoid=objoid};
890+
PgStat_HashKeykey;
884891
PgStatShared_HashEntry*shent;
885892
boolfreed= true;
886893

894+
/* clear padding */
895+
memset(&key,0,sizeof(structPgStat_HashKey));
896+
897+
key.kind=kind;
898+
key.dboid=dboid;
899+
key.objoid=objoid;
900+
887901
/* delete local reference */
888902
if (pgStatEntryRefHash)
889903
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp