pgsql: Fix out-of-bound reads with ascii() for invalid multibyte charac - Mailing list pgsql-committers

From Noah Misch
Subject pgsql: Fix out-of-bound reads with ascii() for invalid multibyte charac
Date
Msg-id E1wtQFq-00000000yB2-1Qm3@gemulon.postgresql.org
Whole thread
List pgsql-committers
Fix out-of-bound reads with ascii() for invalid multibyte characters

This commit addresses two defects in this SQL function, the code
assuming that:
- The user-supplied string was long enough to contain a character of the
length implied by the first byte.  It is possible to provide in input
data that was able to disclose a few bytes of server memory, allowing
out-of-bound reads.
- Specific bytes had values within the expected range, using a set of
assertions to validate them.  The assertions could be triggered on
invalid input.  These are replaced by tests and error reports.

Reported-by: Hcamael <baiyjrh@gmail.com>
Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Backpatch-through: 14
Security: CVE-2026-18024

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/08e812c02ae14bbfb03d787884e4c6087419ecf7
Author: Michael Paquier <michael@paquier.xyz>

Modified Files
--------------
src/backend/utils/adt/oracle_compat.c  | 25 ++++++++++++++++++++-----
src/test/regress/expected/encoding.out | 19 +++++++++++++++++++
src/test/regress/sql/encoding.sql      | 12 ++++++++++++
3 files changed, 51 insertions(+), 5 deletions(-)


Attachment

pgsql-committers by date:

Previous
From: Noah Misch
Date:
Subject: pgsql: Avoid overflow in Levenshtein distance calculations.
Next
From: Noah Misch
Date:
Subject: pgsql: Cross-check the type of a portal running EXECUTE or FETCH.