| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Avoid null pointer crash after pg_localtime()/pg_gmtime() failur |
| Date: | 2026-11-25 02:20:14 |
| Message-ID: | E1xW2cI-00000000D0G-1j6P@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
Avoid null pointer crash after pg_localtime()/pg_gmtime() failure.
localtime(3) and gmtime(3) are specified to return NULL on failure,
and our versions do that too, but most of our call sites did not
guard against such a result. Make them more wary.
Many of these call sites pass the result straight to pg_strftime(),
so the path of least resistance is to harden that function rather
than touch all its callers. I made it return an empty string, as
it already does for other failure cases. In other places the
fallback behavior can be to use UTC timezone.
The possible causes of a NULL result seem to be (a) malloc() failure
or (b) integer overflow in time calculations. Anthropic found a
case where an integer overflow could be triggered with a contrived
POSIX timezone setting; that seems to be a bug in the 2026b tzcode
release we're using in master, which has already been repaired
upstream. Since it won't occur with sane timezone settings, I'm
not going to worry about fixing it before our next tzcode merge.
We should guard against these failure returns in any case.
Reported to security@ by Anthropic, but they described it as a
non-security bug, which matches our policy: a plain NULL-pointer
dereference without any worse consequences is not security material.
Reported-by: Anthropic OSS program
Author: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Backpatch-through: 15
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/93e2b79f5f66ee305338bd956e70a96c9d114ac7
Modified Files
--------------
src/backend/postmaster/syslogger.c | 7 +++--
src/backend/utils/adt/timestamp.c | 52 ++++++++++++++++++++------------------
src/timezone/strftime.c | 11 ++++++++
3 files changed, 43 insertions(+), 27 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2026-11-25 02:20:15 | pgsql: Avoid null pointer crash after pg_localtime()/pg_gmtime() failur |
| Previous Message | Manu | 2026-11-25 01:42:32 | Re: pgsql: Don't trust NOT NULL on virtual generated columns of partitioned |