mirror of
https://github.com/postgres/postgres.git
synced 2025-07-26 01:22:12 +03:00
Fix memory overrun when querying pg_stat_slru
pg_stat_get_slru() in pgstatfuncs.c would point to one element after the end of the array PgStat_SLRUStats when finishing to scan its entries. This had no direct consequences as no data from the extra memory area was read, but static analyzers would rightfully complain here. So let's be clean. While on it, this adds one regression test in the area reserved for system views. Reported-by: Alexander Kozhemyakin, via AddressSanitizer Author: Kyotaro Horiguchi Discussion: https://postgr.es/m/17280-37da556e86032070@postgresql.org Backpatch-through: 13
This commit is contained in:
@ -1911,7 +1911,7 @@ pg_stat_get_slru(PG_FUNCTION_ARGS)
|
||||
/* for each row */
|
||||
Datum values[PG_STAT_GET_SLRU_COLS];
|
||||
bool nulls[PG_STAT_GET_SLRU_COLS];
|
||||
PgStat_SLRUStats stat = stats[i];
|
||||
PgStat_SLRUStats stat;
|
||||
const char *name;
|
||||
|
||||
name = pgstat_slru_name(i);
|
||||
@ -1919,6 +1919,7 @@ pg_stat_get_slru(PG_FUNCTION_ARGS)
|
||||
if (!name)
|
||||
break;
|
||||
|
||||
stat = stats[i];
|
||||
MemSet(values, 0, sizeof(values));
|
||||
MemSet(nulls, 0, sizeof(nulls));
|
||||
|
||||
|
Reference in New Issue
Block a user