| From: | Noah Misch <noah(at)leadboat(dot)com> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Fix potential buffer overrun in regexp match/split functions. |
| Date: | 2026-08-10 13:41:19 |
| Message-ID: | E1wtQFj-00000000y0e-2yc3@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
Fix potential buffer overrun in regexp match/split functions.
setup_regexp_matches() sizes the buffer used to convert matched
substrings back from pg_wchar form at the smaller of maxlen*eml and
the original string's byte length, on the assumption that such a
conversion cannot produce more bytes than the string it came
from. That assumption holds only for validly encoded input. But
pg_mb2wchar_with_len() silently accepts bytes that are invalid in the
database encoding, turning each such byte into one pg_wchar, and
converting that back can take more bytes than the input did. A string
made of such bytes therefore overruns the conversion buffer by up to
its own length, corrupting the following memory. regexp_match(),
regexp_matches(), regexp_split_to_table() and regexp_split_to_array()
are all affected.
Fix by dropping the tighter bound and always allocating maxlen*eml + 1
bytes.
Reported-by: Francesco Verardi <frevadiscor89(at)gmail(dot)com>
Author: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Reviewed-by: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Backpatch-through: 14
Security: CVE-2026-14664
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/343aabf1d95dfb65c0b7c7cdc2e2fb4e79ba9e6d
Author: Masahiko Sawada <msawada(at)postgresql(dot)org>
Modified Files
--------------
src/backend/utils/adt/regexp.c | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Noah Misch | 2026-08-10 13:41:20 | pgsql: Fix pg_trgm's picksplit function with all-true datums |
| Previous Message | John Naylor | 2026-08-10 10:40:03 | Re: pgsql: Rename sort support integer comparators for clarity |