From: Noah Misch <noah@leadboat.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix potential buffer overrun in ts_rank_cd().
Date: Mon, 09 Nov 2026 14:21:57 +0000
Message-ID: <E1xQQFx-000000003a4-0RIg@gemulon.postgresql.org> (raw)
Fix potential buffer overrun in ts_rank_cd().
get_docrep() assumed there could be no more QueryItems per group
than there are lexemes in the input tsvector. That's true with valid
tsvector input, which will never show duplicate positions for any
lexeme. But with duplicate positions it's possible to overrun the
allocated space. Guard against that by dropping items if there are
more than we expect (it doesn't seem worth working harder than that).
The submitted test case that reached this constructed an invalid
tsvector by dint of starting with one, namely a tsvector containing
a zero position, which tsvectorrecv() failed to prevent before
10cc5aa96. It's not clear whether the problem is reachable without
that.
Reported-by: Anthropic OSS program
Author: Anthropic OSS program
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Backpatch-through: 14
Security: CVE-2026-116317
Branch
------
REL_18_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/3e97c9a1fa19fb995e57a1a093cb7cee3f6da605
Author: Tom Lane <tgl@sss.pgh.pa.us>
Modified Files
--------------
src/backend/utils/adt/tsrank.c | 14 ++++++++++++--
src/include/tsearch/ts_type.h | 2 +-
2 files changed, 13 insertions(+), 3 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: noah@leadboat.com
Subject: Re: pgsql: Fix potential buffer overrun in ts_rank_cd().
In-Reply-To: <E1xQQFx-000000003a4-0RIg@gemulon.postgresql.org>
References: <E1xQQFx-000000003a4-0RIg@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox