Re: BUG #19920: Out-of-Bounds Read on a Zero-Length Array in pg_trgm word_similarity('', '')

From: Kirill Reshke <reshkekirill(at)gmail(dot)com>
To: Daniel Gustafsson <daniel(at)yesql(dot)se>
Cc: nakamurajames123(at)gmail(dot)com, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #19920: Out-of-Bounds Read on a Zero-Length Array in pg_trgm word_similarity('', '')
Date: 2026-11-19 12:10:16
Message-ID: CALdSSPjcK3oz+8NivrmcH2vKhdKnrDNTQCMk+JBjba+T0e6+Xw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, 19 Nov 2026, 16:53 Daniel Gustafsson, <daniel(at)yesql(dot)se> wrote:

> > On 19 Nov 2026, at 02:33, PG Bug reporting form <noreply(at)postgresql(dot)org>
> wrote:
>
> > In calc_word_similarity(), an array is allocated with zero elements, but
> the
> > function reads found[0], accessing one byte outside the allocated array
> > bounds.
>
> Verified, the trivial diff attached avoids this.
>
> --
> Daniel Gustafsson
>

I have also found this some time ago with UBSAN, but didn't report due to
no actual server crash. Anyway LGTM

>

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Rajesh Kumar Thandapani 2026-11-19 12:16:15 Re: BUG #19776: pg_combinebackup ignores the truncation_block_length of an intermediate incremental backup
Previous Message Andrey Rachitskiy 2026-11-19 11:55:13 Re: BUG #19918: SIGSEGV in auto_explain + EXPLAIN (BUFFERS)