pgsql: Fix ILIKE patterns with non-ASCII bytes in single-byte encodings

From: Jeff Davis <jdavis(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix ILIKE patterns with non-ASCII bytes in single-byte encodings
Date: 2026-10-21 12:55:01
Message-ID: E1xJVqP-00000000Bm0-2cqB@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix ILIKE patterns with non-ASCII bytes in single-byte encodings.

Commit 1e493158d3d changed the MATCH_LOWER implementation of GETCHAR()
from SB_lower_char() to use pg_ascii_tolower(). The latter returns an
unsigned char; but the local variable in C_IMatchText was a char.

For single-byte encodings and the C locale, that could lead to a
broken signed/unsigned comparison. For example, the pattern
U&'%\00C6' would never match.

Fix by casting the result of pg_ascii_tolower() explicitly to char.

Reported-by: Greg Burd <greg(at)burd(dot)me>
Reviewed-by: Greg Burd <greg(at)burd(dot)me>
Discussion: https://postgr.es/m/_GW2V-rd0QW4BTguAJriA9XVmjOn2mR3-YeAZr9ZU6EtlLvYPEm_r_fV5wGKzSNMzboj_nqn3fk72AYAvOKzEnPlCCHteaYrgESrIhPg6l8=@burd.me
Backpatch-through: 19

Branch
------
REL_19_STABLE

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

Modified Files
--------------
src/backend/utils/adt/like_match.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2026-10-21 14:34:54 pgsql: psql: Fall back to English for unsafe hidden query labels.
Previous Message Jeff Davis 2026-10-21 12:54:48 pgsql: Fix ILIKE patterns with non-ASCII bytes in single-byte encodings