pgsql: Fix multibyte issue in ltree_strncasecmp(). - Mailing list pgsql-committers

From Jeff Davis
Subject pgsql: Fix multibyte issue in ltree_strncasecmp().
Date
Msg-id E1vVa6p-0016v9-1a@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Fix multibyte issue in ltree_strncasecmp().

Previously, the API for ltree_strncasecmp() took two inputs but only
one length (that of the smaller input). It truncated the larger input
to that length, but that could break a multibyte sequence.

Change the API to be a check for prefix equality (possibly
case-insensitive) instead, which is all that's needed by the
callers. Also, provide the lengths of both inputs.

Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Discussion: https://postgr.es/m/5f65b85740197ba6249ea507cddf609f84a6188b.camel%40j-davis.com
Backpatch-through: 14

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/84d5efa7e3ebcf04694d312b0f14ceb35dcdfb8e

Modified Files
--------------
contrib/ltree/lquery_op.c    | 40 ++++++++++++++++++++++++++++------------
contrib/ltree/ltree.h        |  7 +++++--
contrib/ltree/ltxtquery_op.c |  8 ++++----
3 files changed, 37 insertions(+), 18 deletions(-)


pgsql-committers by date:

Previous
From: Noah Misch
Date:
Subject: pgsql: Update .abi-compliance-history for CacheInvalidateHeapTupleInpla
Next
From: Jeff Davis
Date:
Subject: pgsql: Fix multibyte issue in ltree_strncasecmp().