Re: Fix for fragile code in hashtext()

From: Haibo Yan <tristan(dot)yim(at)gmail(dot)com>
To: Jeff Davis <pgsql(at)j-davis(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Fix for fragile code in hashtext()
Date: 2026-08-19 08:14:47
Message-ID: CABXr29Hb31nkj1g2Jmk+1BhAm=3ecGs_pWy4tU++j8CQBnbMxQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Aug 18, 2026 at 2:45 PM Jeff Davis <pgsql(at)j-davis(dot)com> wrote:
>
> This is in the ICU-only non-deterministic collation path, so I don't
> believe there's an actual bug or results change here. But for libc, it
> would have been incorrect.
>
> Regards,
> Jeff Davis
>

The fix looks right to me.

Perhaps the pg_strnxfrm() comment could state more explicitly that the
first call
is only for buffer sizing, while the return value from the actual
transformation is
the authoritative result length. That seems to be the assumption that was
missed
here.

I don’t think a regression test is necessary unless there’s a simple way to
exercise
rsize < bsize; an ICU test would pass both before and after this patch.

Regards,
Haibo

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Gustafsson 2026-08-19 08:31:50 Re: [PATCH] Several refactorings for pg_dump
Previous Message Daniel Gustafsson 2026-08-19 08:11:54 Re: [PATCH] Fix heap-buffer-overflow in PGTYPEStimestamp_defmt_scan()