postgresql/src
Tom Lane ec8ded4b32 Guard against unsafe conditions in usage of pg_strftime().
Although pg_strftime() has defined error conditions, no callers bother
to check for errors.  This is problematic because the output string is
very likely not null-terminated if an error occurs, so that blindly
using it is unsafe.  Rather than trusting that we can find and fix all
the callers, let's alter the function's API spec slightly: make it
guarantee a null-terminated result so long as maxsize > 0.

Furthermore, if we do get an error, let's make that null-terminated
result be an empty string.  We could instead truncate at the buffer
length, but that risks producing mis-encoded output if the tz_name
string contains multibyte characters.  It doesn't seem reasonable for
src/timezone/ to make use of our encoding-aware truncation logic.
Also, the only really likely source of a failure is a user-supplied
timezone name that is intentionally trying to overrun our buffers.
I don't feel a need to be particularly friendly about that case.

Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: John Naylor <johncnaylorls@gmail.com>
Backpatch-through: 14
Security: CVE-2026-6474
2026-05-11 05:13:46 -07:00
..
backend Avoid passing unintended format codes to snprintf(). 2026-05-11 05:13:46 -07:00
bin pg_upgrade: Message improvements 2026-05-11 11:38:20 +02:00
common Fix assorted places that need to use palloc_array(). 2026-05-11 05:13:46 -07:00
fe_utils Rework signal handler infrastructure to pass sender info as argument. 2026-04-15 07:30:34 -04:00
include Harden our regex engine against integer overflow in size calculations. 2026-05-11 05:13:46 -07:00
interfaces Apply timingsafe_bcmp() in authentication paths 2026-05-11 05:13:46 -07:00
makefiles Add CONCURRENTLY option to REPACK 2026-04-06 21:55:08 +02:00
pl Harmonize function parameter names for Postgres 19. 2026-04-22 12:47:19 -04:00
port Fix universal builds on MacOS 2026-05-08 16:44:25 +07:00
template Switch the semaphore API on Solaris to unnamed POSIX. 2026-03-14 14:10:32 -04:00
test Fix SQL injection in logical replication origin checks. 2026-05-11 05:13:46 -07:00
timezone Guard against unsafe conditions in usage of pg_strftime(). 2026-05-11 05:13:46 -07:00
tools Consider opfamily and collation when removing redundant GROUP BY columns 2026-05-08 12:45:51 +09:00
tutorial Force standard_conforming_strings to always be ON. 2026-01-21 15:08:38 -05:00
.gitignore
DEVELOPERS
Makefile Add CONCURRENTLY option to REPACK 2026-04-06 21:55:08 +02:00
Makefile.global.in Update Unicode data to CLDR 48.2 2026-04-13 11:13:36 +02:00
Makefile.shlib Restore AIX support. 2026-02-23 13:34:22 -05:00
meson.build Update copyright for 2026 2026-01-01 13:24:10 -05:00
nls-global.mk Fix update-po for the PGXS case 2025-10-16 20:21:05 +02:00