Fix potential buffer overrun in tsvector_delete().

tsvector_delete_by_indices() sized its output as VARSIZE(input) on the
assumption that the result can never be larger, but that only holds
when the input's lexeme data area is laid out in WordEntry order, like
the output's will be.  With a different ordering, additional pad bytes
could be needed for alignment of position data.  ts_type.h explicitly
says that a different lexeme data ordering is legal, and
tsvectorrecv() for one can produce other orderings.  To fix, use the
same solution as tsvector_concat(): allocate one extra byte per
output lexeme.  That's probably considerably more than enough, but
it's not worth working harder.

Reported-by: Anthropic OSS program
Author: Anthropic OSS program
Reviewed-by: Tom Lane <[email protected]>
Backpatch-through: 14
Security: CVE-2026-116315

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/27dfe0e341c30cdc156a849034268f5dc38c1d29
Author: Tom Lane <[email protected]>

Modified Files
--------------
src/backend/utils/adt/tsvector_op.c | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)

Reply via email to