pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Don't reference out-of-bounds array elements in brin_minmax_mult
3+ messages / 1 participants
[nested] [flat]

* pgsql: Don't reference out-of-bounds array elements in brin_minmax_mult
@ 2022-09-12 23:04 David Rowley <drowley@postgresql.org>
  0 siblings, 0 replies; 3+ messages in thread

From: David Rowley @ 2022-09-12 23:04 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Don't reference out-of-bounds array elements in brin_minmax_multi.c

The primary fix here is to fix has_matching_range() so it does not
reference ranges->values[-1] when nranges == 0.  Similar problems existed
in AssertCheckRanges() too.  It does not look like any of these problems
could lead to a crash as the array in question is at the end of the Ranges
struct, and values[-1] is memory that belongs to other fields in the
struct.  However, let's get rid of these rather unsafe coding practices.

In passing, I (David) adjusted some comments to try to make it more clear
what some of the fields are for in the Ranges struct.  I had to study the
code to find out what nsorted was for as I couldn't tell from the
comments.

Author: Ranier Vilela
Discussion: https://postgr.es/m/CAEudQAqJQzPitufX-jR=YUbJafpCDAKUnwgdbX_MzSc93wuvdw@mail.gmail.com
Backpatch-through: 14, where multi-range brin was added.

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/6b89ce1a21f909f616db165dcc6d8d2918fbc185

Modified Files
--------------
src/backend/access/brin/brin_minmax_multi.c | 172 ++++++++++++++--------------
1 file changed, 88 insertions(+), 84 deletions(-)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* pgsql: Don't reference out-of-bounds array elements in brin_minmax_mult
@ 2022-09-12 23:05 David Rowley <drowley@postgresql.org>
  0 siblings, 0 replies; 3+ messages in thread

From: David Rowley @ 2022-09-12 23:05 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Don't reference out-of-bounds array elements in brin_minmax_multi.c

The primary fix here is to fix has_matching_range() so it does not
reference ranges->values[-1] when nranges == 0.  Similar problems existed
in AssertCheckRanges() too.  It does not look like any of these problems
could lead to a crash as the array in question is at the end of the Ranges
struct, and values[-1] is memory that belongs to other fields in the
struct.  However, let's get rid of these rather unsafe coding practices.

In passing, I (David) adjusted some comments to try to make it more clear
what some of the fields are for in the Ranges struct.  I had to study the
code to find out what nsorted was for as I couldn't tell from the
comments.

Author: Ranier Vilela
Discussion: https://postgr.es/m/CAEudQAqJQzPitufX-jR=YUbJafpCDAKUnwgdbX_MzSc93wuvdw@mail.gmail.com
Backpatch-through: 14, where multi-range brin was added.

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/4d5d35858c898a64a96cdff62d6d1ff9f08f9fa5

Modified Files
--------------
src/backend/access/brin/brin_minmax_multi.c | 172 ++++++++++++++--------------
1 file changed, 88 insertions(+), 84 deletions(-)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* pgsql: Don't reference out-of-bounds array elements in brin_minmax_mult
@ 2022-09-12 23:05 David Rowley <drowley@postgresql.org>
  0 siblings, 0 replies; 3+ messages in thread

From: David Rowley @ 2022-09-12 23:05 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Don't reference out-of-bounds array elements in brin_minmax_multi.c

The primary fix here is to fix has_matching_range() so it does not
reference ranges->values[-1] when nranges == 0.  Similar problems existed
in AssertCheckRanges() too.  It does not look like any of these problems
could lead to a crash as the array in question is at the end of the Ranges
struct, and values[-1] is memory that belongs to other fields in the
struct.  However, let's get rid of these rather unsafe coding practices.

In passing, I (David) adjusted some comments to try to make it more clear
what some of the fields are for in the Ranges struct.  I had to study the
code to find out what nsorted was for as I couldn't tell from the
comments.

Author: Ranier Vilela
Discussion: https://postgr.es/m/CAEudQAqJQzPitufX-jR=YUbJafpCDAKUnwgdbX_MzSc93wuvdw@mail.gmail.com
Backpatch-through: 14, where multi-range brin was added.

Branch
------
REL_14_STABLE

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

Modified Files
--------------
src/backend/access/brin/brin_minmax_multi.c | 172 ++++++++++++++--------------
1 file changed, 88 insertions(+), 84 deletions(-)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2022-09-12 23:05 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-09-12 23:04 pgsql: Don't reference out-of-bounds array elements in brin_minmax_mult David Rowley <drowley@postgresql.org>
2022-09-12 23:05 pgsql: Don't reference out-of-bounds array elements in brin_minmax_mult David Rowley <drowley@postgresql.org>
2022-09-12 23:05 pgsql: Don't reference out-of-bounds array elements in brin_minmax_mult David Rowley <drowley@postgresql.org>

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