about summary refs log tree commit diff
path: root/src/time
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2013-07-17 10:39:11 -0400
committerRich Felker <dalias@aerifal.cx>2013-07-17 10:39:11 -0400
commitea81c0624f0213430ae8fb959e30373eeaaf391c (patch)
tree465459ee633ceb927202de641a77f5adbfa31999 /src/time
parentac1bf93fc634274c14d234c44b2e846a93a5cc95 (diff)
downloadmusl-ea81c0624f0213430ae8fb959e30373eeaaf391c.tar.gz
musl-ea81c0624f0213430ae8fb959e30373eeaaf391c.tar.xz
musl-ea81c0624f0213430ae8fb959e30373eeaaf391c.zip
fix error code on time conversion overflows
POSIX mandates EOVERFLOW for this condition.
Diffstat (limited to 'src/time')
-rw-r--r--src/time/gmtime_r.c2
-rw-r--r--src/time/localtime_r.c2
-rw-r--r--src/time/mktime.c2
-rw-r--r--src/time/timegm.c2
4 files changed, 4 insertions, 4 deletions
diff --git a/src/time/gmtime_r.c b/src/time/gmtime_r.c
index 0272870d..fee01bd6 100644
--- a/src/time/gmtime_r.c
+++ b/src/time/gmtime_r.c
@@ -5,7 +5,7 @@
 struct tm *__gmtime_r(const time_t *restrict t, struct tm *restrict tm)
 {
 	if (__secs_to_tm(*t, tm) < 0) {
-		errno = EINVAL;
+		errno = EOVERFLOW;
 		return 0;
 	}
 	tm->tm_isdst = 0;
diff --git a/src/time/localtime_r.c b/src/time/localtime_r.c
index b36c1d82..c52678fd 100644
--- a/src/time/localtime_r.c
+++ b/src/time/localtime_r.c
@@ -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);
 	if (__secs_to_tm((long long)*t - tm->__tm_gmtoff, tm) < 0) {
-		errno = EINVAL;
+		errno = EOVERFLOW;
 		return 0;
 	}
 	return tm;
diff --git a/src/time/mktime.c b/src/time/mktime.c
index e38b4619..ef1fb425 100644
--- a/src/time/mktime.c
+++ b/src/time/mktime.c
@@ -25,6 +25,6 @@ time_t mktime(struct tm *tm)
 	return t;
 
 error:
-	errno = EINVAL;
+	errno = EOVERFLOW;
 	return -1;
 }
diff --git a/src/time/timegm.c b/src/time/timegm.c
index 7148fca3..e7a7939b 100644
--- a/src/time/timegm.c
+++ b/src/time/timegm.c
@@ -7,7 +7,7 @@ time_t timegm(struct tm *tm)
 	struct tm new;
 	long long t = __tm_to_secs(tm);
 	if (__secs_to_tm(t, &new) < 0) {
-		errno = EINVAL;
+		errno = EOVERFLOW;
 		return -1;
 	}
 	*tm = new;