mirror of
https://github.com/fluencelabs/musl
synced 2025-05-29 15:41:36 +00:00
fix error code on time conversion overflows
POSIX mandates EOVERFLOW for this condition.
This commit is contained in:
parent
ac1bf93fc6
commit
ea81c0624f
@ -5,7 +5,7 @@
|
|||||||
struct tm *__gmtime_r(const time_t *restrict t, struct tm *restrict tm)
|
struct tm *__gmtime_r(const time_t *restrict t, struct tm *restrict tm)
|
||||||
{
|
{
|
||||||
if (__secs_to_tm(*t, tm) < 0) {
|
if (__secs_to_tm(*t, tm) < 0) {
|
||||||
errno = EINVAL;
|
errno = EOVERFLOW;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
tm->tm_isdst = 0;
|
tm->tm_isdst = 0;
|
||||||
|
@ -6,7 +6,7 @@ struct tm *__localtime_r(const time_t *restrict t, struct tm *restrict tm)
|
|||||||
{
|
{
|
||||||
__secs_to_zone(*t, 0, &tm->tm_isdst, &tm->__tm_gmtoff, 0, &tm->__tm_zone);
|
__secs_to_zone(*t, 0, &tm->tm_isdst, &tm->__tm_gmtoff, 0, &tm->__tm_zone);
|
||||||
if (__secs_to_tm((long long)*t - tm->__tm_gmtoff, tm) < 0) {
|
if (__secs_to_tm((long long)*t - tm->__tm_gmtoff, tm) < 0) {
|
||||||
errno = EINVAL;
|
errno = EOVERFLOW;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return tm;
|
return tm;
|
||||||
|
@ -25,6 +25,6 @@ time_t mktime(struct tm *tm)
|
|||||||
return t;
|
return t;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
errno = EINVAL;
|
errno = EOVERFLOW;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ time_t timegm(struct tm *tm)
|
|||||||
struct tm new;
|
struct tm new;
|
||||||
long long t = __tm_to_secs(tm);
|
long long t = __tm_to_secs(tm);
|
||||||
if (__secs_to_tm(t, &new) < 0) {
|
if (__secs_to_tm(t, &new) < 0) {
|
||||||
errno = EINVAL;
|
errno = EOVERFLOW;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
*tm = new;
|
*tm = new;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user