From 1005b45ca80be850d637e2e925fa90437b865d26 Mon Sep 17 00:00:00 2001 From: jofrev Date: Thu, 8 Dec 2022 22:29:01 +0000 Subject: [PATCH 1/2] Set errno in adjtime if newlib time funcs are not implemented Other time functions (e.g. settimeofday) set errno to ENOSYS if IMPL_NEWLIB_TIME_FUNCS is not set. adjtime should probably do the same. --- components/newlib/time.c | 1 + 1 file changed, 1 insertion(+) diff --git a/components/newlib/time.c b/components/newlib/time.c index 73fc04e5cc0..638beb19a4f 100644 --- a/components/newlib/time.c +++ b/components/newlib/time.c @@ -139,6 +139,7 @@ int adjtime(const struct timeval *delta, struct timeval *outdelta) } return 0; #else + errno = ENOSYS; return -1; #endif } From 60767c234daaea9dfa8b4fa8f721f565b163c3e0 Mon Sep 17 00:00:00 2001 From: jofrev Date: Thu, 8 Dec 2022 22:32:31 +0000 Subject: [PATCH 2/2] Set errno in adjtime if delta is too large errno should be set to EINVAL in this case according to adjtime's man page. --- components/newlib/time.c | 1 + 1 file changed, 1 insertion(+) diff --git a/components/newlib/time.c b/components/newlib/time.c index 638beb19a4f..44c4499c145 100644 --- a/components/newlib/time.c +++ b/components/newlib/time.c @@ -123,6 +123,7 @@ int adjtime(const struct timeval *delta, struct timeval *outdelta) int64_t sec = delta->tv_sec; int64_t usec = delta->tv_usec; if(llabs(sec) > ((INT_MAX / 1000000L) - 1L)) { + errno = EINVAL; return -1; } /*