postgres.git / summary / log / commit / refs

commit    c00a97b646c04c0d895cca44a2b24ad7abec8a6c
Author:   Jeff Davis <jdavis@postgresql.org>
Date:     Wed Oct 21 12:46:37 2026 +0000
First released in: 19.0

    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@burd.me>
    Reviewed-by: Greg Burd <greg@burd.me>
    Discussion: https://postgr.es/m/_GW2V-rd0QW4BTguAJriA9XVmjOn2mR3-YeAZr9ZU6EtlLvYPEm_r_fV5wGKzSNMzboj_nqn3fk72AYAvOKzEnPlCCHteaYrgESrIhPg6l8=@burd.me
    Backpatch-through: 19


src/backend/utils/adt/like_match.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/backend/utils/adt/like_match.c b/src/backend/utils/adt/like_match.c index defcaa96fb5..0249eb49a7d 100644 --- a/src/backend/utils/adt/like_match.c +++ b/src/backend/utils/adt/like_match.c @@ -75,7 +75,8 @@ * locales must casefold the inputs before matching. */ #ifdef MATCH_LOWER -#define GETCHAR(t) pg_ascii_tolower(t) +/* cast to char to match data types in caller */ +#define GETCHAR(t) ((char) pg_ascii_tolower(t)) #else #define GETCHAR(t) (t) #endif [parent: 6b9f40d49ae3]