From abf079b2d82cc3635863672371a2c53f8e940ba1 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Fri, 29 Jul 2016 13:11:04 -0700 Subject: Fix touch(1) date parsing on tzcode-derived systems. The IANA tzcode implementation of mktime (used on Android and BSDs) sets errno in some cases where it doesn't return -1 to indicate failure, so the existing test always failed on those systems. I don't think glibc ever sets errno (which is fine by ISO C, but not POSIX). Other uses of mktime in toybox are already fine. This one would have been caught by the existing tests if I was running them on the device :-( --- toys/posix/touch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'toys') diff --git a/toys/posix/touch.c b/toys/posix/touch.c index 22a1e2e8..cd7dd53d 100644 --- a/toys/posix/touch.c +++ b/toys/posix/touch.c @@ -97,7 +97,7 @@ void touch_main(void) errno = 0; ts->tv_sec = mktime(&tm); - if (!s || *s || errno == EOVERFLOW) perror_exit("bad '%s'", date); + if (!s || *s || ts->tv_sec == -1) perror_exit("bad '%s'", date); } ts[1]=ts[0]; -- cgit v1.2.3