pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix memory overrun when querying pg_stat_slru
Date: Fri, 12 Nov 2021 12:51:36 +0000
Message-ID: <E1mlW1o-00072P-KI@gemulon.postgresql.org> (raw)

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

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/a691a229831ad3b72d933b1858c76be44b508400

Modified Files
--------------
src/backend/utils/adt/pgstatfuncs.c    | 3 ++-
src/test/regress/expected/sysviews.out | 7 +++++++
src/test/regress/sql/sysviews.sql      | 3 +++
3 files changed, 12 insertions(+), 1 deletion(-)



view thread (3+ messages)

Message-ID: <E1mlW1o-00072P-KI@gemulon.postgresql.org>
Permalink:  ../E1mlW1o-00072P-KI@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1mlW1o-00072P-KI@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz
  Subject: Re: pgsql: Fix memory overrun when querying pg_stat_slru
  In-Reply-To: <E1mlW1o-00072P-KI@gemulon.postgresql.org>
  References: <E1mlW1o-00072P-KI@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox