Re: Speed up ICU case conversion by using ucasemap_utf8To*()

Jeff Davis <pgsql@j-davis.com>

From: Jeff Davis <pgsql@j-davis.com>
To: Andreas Karlsson <andreas@proxel.se>, Alexander Lakhin <exclusion@gmail.com>, zengman <zengman@halodbtech.com>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2026-04-13T18:40:03Z
Lists: pgsql-hackers
On Wed, 2026-04-01 at 02:46 +0200, Andreas Karlsson wrote:
> On 3/12/26 5:00 AM, Alexander Lakhin wrote:
> > I've discovered that starting from c4ff35f10, the following query:
> > CREATE COLLATION c (provider = icu, locale = 'icu_something');
> > 
> > makes asan detect (maybe dubious, but still..) stack-buffer-
> > overflow:
> > ==21963==ERROR: AddressSanitizer: stack-buffer-overflow on address 
> 
> My proposed fix is that we allocate a ULOC_LANG_CAPACITY buffer for
> the 
> language like we do in fix_icu_locale_str() instead of trying to be 
> clever.

Thank you both!

Committed with minor revisions:

* also check the status code, just to be sure
* backport to 18 where the original code was introduced

Regards,
	Jeff Davis




Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Check for unterminated strings when calling uloc_getLanguage().

  2. Fix overrun when comparing with unterminated ICU language string.

  3. ICU: use UTF8-optimized case conversion API