From: | Daniel Gustafsson <daniel(at)yesql(dot)se> |
---|---|
To: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> |
Cc: | Алена Васильева <gorcom2012(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: [PATCH] Handle out-of-range timestamps in timestamptz_to_str() |
Date: | 2025-10-15 09:17:14 |
Message-ID: | FF10BEA9-2268-4D6D-BA5E-DA89EEA5BA24@yesql.se |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
> On 15 Oct 2025, at 11:12, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> wrote:
>> On Oct 15, 2025, at 16:54, Алена Васильева <gorcom2012(at)gmail(dot)com> wrote:
>> The function timestamptz_to_str() in src/bin/pg_waldump/compat.c does not
>> handle the case when localtime() returns NULL, which can happen for timestamps
>> that are out of the supported time_t range on some platforms.
>>
>> This patch adds a simple check for a NULL return value and ensures that the
>> function returns a clear error string "(timestamp out of range)" instead of
>> causing undefined behavior or a crash.
Ah yes, thanks for the reminder, it's been on my todo from
EAB008E3-6B87-413F-BA39-22A6ED5DF0F6(at)yesql(dot)se for some time.
> I think we can just return a static const string, without copying the string into “buf" as the function returns a “const char *”.
The function is documented as returning a value pointing to a static buffer, so
it seems better to consistently use that buffer.
--
Daniel Gustafsson
From | Date | Subject | |
---|---|---|---|
Next Message | Andrei Lepikhov | 2025-10-15 09:26:45 | Re: MergeAppend could consider sorting cheapest child path |
Previous Message | Chao Li | 2025-10-15 09:12:53 | Re: [PATCH] Handle out-of-range timestamps in timestamptz_to_str() |