postgresql/src/test/modules
Thomas Munro fd82ddb679 Replace pg_mblen() with bounds-checked versions.
A corrupted string could cause code that iterates with pg_mblen() to
overrun its buffer.  Fix, by converting all callers to one of the
following:

1. Callers with a null-terminated string now use pg_mblen_cstr(), which
raises an "illegal byte sequence" error if it finds a terminator in the
middle of the sequence.

2. Callers with a length or end pointer now use either
pg_mblen_with_len() or pg_mblen_range(), for the same effect, depending
on which of the two seems more convenient at each site.

3. A small number of cases pre-validate a string, and can use
pg_mblen_unbounded().

The traditional pg_mblen() function and COPYCHAR macro still exist for
backward compatibility, but are no longer used by core code and are
hereby deprecated.  The same applies to the t_isXXX() functions.

Security: CVE-2026-2006
Backpatch-through: 14
Co-authored-by: Thomas Munro <thomas.munro@gmail.com>
Co-authored-by: Noah Misch <noah@leadboat.com>
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
Reported-by: Paul Gerste (as part of zeroday.cloud)
Reported-by: Moritz Sanft (as part of zeroday.cloud)
2026-02-09 12:34:24 +13:00
..
brin BRIN autosummarization may need a snapshot 2025-11-04 13:23:26 +01:00
commit_ts Replace Test::More plans with done_testing 2022-02-11 20:54:44 +01:00
delay_execution Remove non-functional code for unloading loadable modules. 2022-05-11 15:30:30 -04:00
dummy_index_am Revert changes in HOT handling of BRIN indexes 2022-06-16 15:02:49 +02:00
dummy_seclabel Update copyright for 2022 2022-01-07 19:04:57 -05:00
libpq_pipeline Fix incorrect error message in libpq_pipeline 2023-06-23 17:50:23 +09:00
plsample Extend plsample example to include a trigger handler. 2022-04-07 18:26:20 -04:00
snapshot_too_old Reduce test runtime of src/test/modules/snapshot_too_old. 2022-08-03 11:14:55 -04:00
spgist_name_ops pg_upgrade: Preserve relfilenodes and tablespace OIDs. 2022-01-17 13:40:27 -05:00
ssl_passphrase_callback Pre-beta mechanical code beautification. 2022-05-12 15:17:30 -04:00
test_bloomfilter Update copyright for 2022 2022-01-07 19:04:57 -05:00
test_ddl_deparse Fix DDL deparse of CREATE OPERATOR CLASS 2022-05-20 18:52:55 +02:00
test_escape With GB18030, prevent SIGSEGV from reading past end of allocation. 2025-05-05 04:52:08 -07:00
test_extensions Reject substituting extension schemas or owners matching ["$'\]. 2023-08-07 06:06:00 -07:00
test_ginpostinglist Update copyright for 2022 2022-01-07 19:04:57 -05:00
test_integerset Update copyright for 2022 2022-01-07 19:04:57 -05:00
test_misc Fix assertion failure with replication slot release in single-user mode 2025-08-20 15:00:14 +09:00
test_oat_hooks Disable debug_discard_caches in test_oat_hooks test. 2022-11-19 13:42:53 -05:00
test_parser Update copyright for 2022 2022-01-07 19:04:57 -05:00
test_pg_dump Drop global objects after completed test 2024-09-24 12:10:25 +09:00
test_predtest Tighten test_predtest's input checks, and improve error messages. 2024-06-07 16:45:56 -04:00
test_rbtree Update copyright for 2022 2022-01-07 19:04:57 -05:00
test_regex Replace pg_mblen() with bounds-checked versions. 2026-02-09 12:34:24 +13:00
test_rls_hooks Remove non-functional code for unloading loadable modules. 2022-05-11 15:30:30 -04:00
test_shm_mq Use correct DatumGet*() function in test_shm_mq_main(). 2025-06-27 13:37:26 -05:00
unsafe_tests Fix per-session activation of ALTER {ROLE|DATABASE} SET role. 2024-11-15 20:39:59 -08:00
worker_spi pgstat: store statistics in shared memory. 2022-04-06 21:29:46 -07:00
Makefile Add test of various escape functions 2025-02-10 10:03:39 -05:00
README Add an enforcement mechanism for global object names in regression tests. 2019-06-29 11:34:00 -04:00

Test extensions and libraries
=============================

src/test/modules contains PostgreSQL extensions that are primarily or entirely
intended for testing PostgreSQL and/or to serve as example code. The extensions
here aren't intended to be installed in a production server and aren't suitable
for "real work".

Furthermore, while you can do "make install" and "make installcheck" in
this directory or its children, it is NOT ADVISABLE to do so with a server
containing valuable data.  Some of these tests may have undesirable
side-effects on roles or other global objects within the tested server.
"make installcheck-world" at the top level does not recurse into this
directory.

Most extensions have their own pg_regress tests or isolationtester specs. Some
are also used by tests elsewhere in the tree.

If you're adding new hooks or other functionality exposed as C-level API this
is where to add the tests for it.