Re: Fix for fragile code in ltree/crc32.c

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Rithvika Devisetti <devisettirithvika(at)gmail(dot)com>, Jeff Davis <pgsql(at)j-davis(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Fix for fragile code in ltree/crc32.c
Date: 2026-08-25 08:15:25
Message-ID: 8a3b047f-f154-4b12-9160-c0af71c9ccf4@iki.fi
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 25/08/2026 11:13, Heikki Linnakangas wrote:
>> /*
>>  * Expansion factor of string length, not including terminating NUL.
>> That is,
>>  * the upper bound of the number of multibyte characters in the result
>> string
>>  * per multibyte character in the input string.
>>  *
>>  * NB: assumes no provider exceeds the Unicode-defined maximum.
>>  */
>> #define PG_MAX_CASEMAP_MBCHARS        UNICODE_MAX_CASEMAP_CODEPOINTS
>
> Is it a number of codepoints or bytes? The comment says "multibyte
> characters" which I think means codepoints in unicode, but the ltree
> code does this:
>
>>         /* max space required to map single codepoint, including NUL */
>>         char        foldstr[PG_CASEMAP_BUFSZ];
>
> Which sure looks like # of bytes.

Never mind. Just after sending this I saw that PG_CASEMAP_BUFSZ is
different from PG_MAX_CASEMAP_MBCHARS. Sorry for the noise.

- Heikki

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Gustafsson 2026-08-25 08:16:41 Re: Replace px_memset() with explicit_bzero()
Previous Message Peter Eisentraut 2026-08-25 08:14:02 Replace px_memset() with explicit_bzero()