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

Commita691a22

Browse files
committed
Fix memory overrun when querying pg_stat_slru
pg_stat_get_slru() in pgstatfuncs.c would point to one element after theend of the array PgStat_SLRUStats when finishing to scan its entries.This had no direct consequences as no data from the extra memory areawas read, but static analyzers would rightfully complain here. So let'sbe clean.While on it, this adds one regression test in the area reserved forsystem views.Reported-by: Alexander Kozhemyakin, via AddressSanitizerAuthor: Kyotaro HoriguchiDiscussion:https://postgr.es/m/17280-37da556e86032070@postgresql.orgBackpatch-through: 13
1 parentd4e9d69 commita691a22

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

‎src/backend/utils/adt/pgstatfuncs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1744,14 +1744,15 @@ pg_stat_get_slru(PG_FUNCTION_ARGS)
17441744
/* for each row */
17451745
Datumvalues[PG_STAT_GET_SLRU_COLS];
17461746
boolnulls[PG_STAT_GET_SLRU_COLS];
1747-
PgStat_SLRUStatsstat=stats[i];
1747+
PgStat_SLRUStatsstat;
17481748
constchar*name;
17491749

17501750
name=pgstat_slru_name(i);
17511751

17521752
if (!name)
17531753
break;
17541754

1755+
stat=stats[i];
17551756
MemSet(values,0,sizeof(values));
17561757
MemSet(nulls,0,sizeof(nulls));
17571758

‎src/test/regress/expected/sysviews.out

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ select count(*) >= 0 as ok from pg_prepared_xacts;
6767
t
6868
(1 row)
6969

70+
-- There will surely be at least one SLRU cache
71+
select count(*) > 0 as ok from pg_stat_slru;
72+
ok
73+
----
74+
t
75+
(1 row)
76+
7077
-- We expect no walreceiver running in this test
7178
select count(*) = 0 as ok from pg_stat_wal_receiver;
7279
ok

‎src/test/regress/sql/sysviews.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ select count(*) = 0 as ok from pg_prepared_statements;
3232
-- See also prepared_xacts.sql
3333
selectcount(*)>=0as okfrom pg_prepared_xacts;
3434

35+
-- There will surely be at least one SLRU cache
36+
selectcount(*)>0as okfrom pg_stat_slru;
37+
3538
-- We expect no walreceiver running in this test
3639
selectcount(*)=0as okfrom pg_stat_wal_receiver;
3740

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp