Missing checks on return value of timestamp2tm in datetime.c

Started by Michael Paquieralmost 11 years ago2 messageshackers
Jump to latest
#1Michael Paquier
michael@paquier.xyz

Hi all,

timestamp2tm is called close to 40 times in the backend source code,
returning -1 in case of failure. However, there are two places in
datetime.c where we do not check for its return value: GetCurrentDateTime
and GetCurrentTimeUsec.
This does not really matter much in practice as the timestamp used is
GetCurrentTransactionStartTimestamp(), but for correctness shouldn't we
check for its return code and report ERRCODE_DATETIME_VALUE_OUT_OF_RANGE on
error?

Per se the patch attached.
Regards,
--
Michael

#2Michael Paquier
michael@paquier.xyz
In reply to: Michael Paquier (#1)
Re: Missing checks on return value of timestamp2tm in datetime.c

On Tue, Jun 30, 2015 at 9:45 PM, Michael Paquier
<michael.paquier@gmail.com> wrote:

timestamp2tm is called close to 40 times in the backend source code,
returning -1 in case of failure. However, there are two places in datetime.c
where we do not check for its return value: GetCurrentDateTime and
GetCurrentTimeUsec.
This does not really matter much in practice as the timestamp used is
GetCurrentTransactionStartTimestamp(), but for correctness shouldn't we
check for its return code and report ERRCODE_DATETIME_VALUE_OUT_OF_RANGE on
error?

Per se the patch attached.

And here is the patch.
(Thanks David R. for the poke).
--
Michael

Attachments:

20150630_datetime_checks.patchtext/x-patch; charset=US-ASCII; name=20150630_datetime_checks.patchDownload+10-4