libc/stdtime: Set errno to EOVERFLOW when there is an overflow.
authorSascha Wildner <saw@online.de>
Tue, 3 May 2022 01:31:11 +0000 (03:31 +0200)
committerSascha Wildner <saw@online.de>
Tue, 3 May 2022 01:31:11 +0000 (03:31 +0200)
commit56e344b830405b4e9841e03b20c5479e3d82308f
tree12f3b6a8250cdd47a44dc184815d40dded1c88f6
parentb430e9122ef2bb6f0cc6fc04292295f75a860a08
libc/stdtime: Set errno to EOVERFLOW when there is an overflow.

This fixes various issues such as gmtime() returning NULL on an
out-of-bounds time_t but not setting errno, as POSIX requires.

Also, in ctime() and ctime_r(), check the result of localtime()
before passing it to asctime{,_r}().

See:
https://github.com/eggert/tz/commit/4d306b3a17ce5ce0b33a73a90dc713d3601ea89a
lib/libc/stdtime/localtime.c