postgresql/src/backend
Tom Lane 17f72e037f Prevent buffer overrun in spell.c's CheckAffix().
This function writes into a caller-supplied buffer of length
2 * MAXNORMLEN, which should be plenty in real-world cases.
However a malicious affix file could supply an affix long
enough to overrun that.  Defend by just rejecting the match
if it would overrun the buffer.  I also inserted a check of
the input word length against Affix->replen, just to be sure
we won't index off the buffer, though it would be caller error
for that not to be true.

Also make the actual copying steps a bit more readable, and remove
an unnecessary requirement for the whole input word to fit into the
output buffer (even though it always will with the current caller).

The lack of documentation in this code makes my head hurt, so
I also reverse-engineered a basic header comment for CheckAffix.

Reported-by: Xint Code
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>
Discussion: https://postgr.es/m/641711.1776792744@sss.pgh.pa.us
Backpatch-through: 14
2026-04-22 11:06:47 -04:00
..
access Fix multixact backwards-compatibility with CHECKPOINT race condition 2026-03-23 12:02:27 +02:00
archive Redesign archive modules 2023-02-17 14:26:42 +09:00
backup Fix error message related to end TLI in backup manifest 2026-01-18 17:25:01 +09:00
bootstrap Fix CREATE INDEX progress reporting for multi-level partitioning. 2023-03-25 15:34:03 -04:00
catalog Fix some cases of indirectly casting away const. 2026-02-25 11:19:50 -05:00
commands Allow ALTER INDEX .. ATTACH PARTITION to validate a parent index 2026-04-22 10:34:37 +09:00
executor Fix integer overflow in nodeWindowAgg.c 2026-04-09 19:34:02 +09:00
foreign Restrict accesses to non-system views and foreign tables during pg_dump. 2024-08-05 06:05:28 -07:00
jit jit: No backport::SectionMemoryManager for LLVM 22. 2026-04-03 15:01:56 +13:00
lib Accommodate very large dshash tables. 2024-12-17 15:24:45 -06:00
libpq Fix build breakage on Solaris-alikes with late-model GCC. 2025-07-23 15:44:29 -04:00
main Avoid possible crash within libsanitizer. 2025-11-05 11:09:30 -05:00
nodes Build whole-row Vars the same way during parsing and planning. 2025-03-12 11:47:19 -04:00
optimizer Fix relid-set clobber during join removal. 2026-04-20 19:24:46 -04:00
parser Fix possible incorrect column reference in ERROR message 2026-01-09 11:03:48 +13:00
partitioning Fix creation of partition descriptor during concurrent detach+drop 2024-08-12 18:17:56 -04:00
po Translation updates 2026-02-23 14:02:22 +01:00
port Don't treat EINVAL from semget() as a hard failure. 2025-08-13 11:59:47 -04:00
postmaster Fix orphaned processes when startup process fails during PM_STARTUP 2026-04-21 09:40:06 +09:00
regex Avoid assertion due to disconnected NFA sub-graphs in regex parsing. 2024-11-15 18:23:38 -05:00
replication Flush statistics during idle periods in parallel apply worker. 2026-04-20 10:13:55 +05:30
rewrite Fix incorrect NEW references to generated columns in rule rewriting 2026-04-21 14:33:07 +09:00
snowball Avoid null pointer dereference crash after OOM in Snowball stemmers. 2025-02-18 21:23:59 -05:00
statistics Fix set of issues with extended statistics on expressions 2026-03-02 09:38:44 +09:00
storage Fix ProcWakeup() resetting wrong waitStart field. 2026-02-26 08:50:56 +09:00
tcop Check for CREATE privilege on the schema in CREATE STATISTICS. 2025-11-10 09:00:00 -06:00
tsearch Prevent buffer overrun in spell.c's CheckAffix(). 2026-04-22 11:06:47 -04:00
utils Honor passed-in database OIDs in pgstat_database.c 2026-04-11 17:03:08 +09:00
.gitignore
common.mk Blind attempt to fix LLVM dependency in the backend 2022-09-15 10:53:48 +07:00
Makefile Fix make headerscheck 2024-04-27 11:38:41 +07:00
meson.build Add win32ver data to meson-built postgres.exe. 2023-06-12 07:40:38 -07:00
nls.mk Add missing gettext triggers 2023-05-10 13:51:51 +02:00