diff options
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | Src/Modules/datetime.c | 2 | ||||
-rw-r--r-- | Test/V09datetime.ztst | 5 |
3 files changed, 12 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog index ac8524bd0..8f92c8e34 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,10 @@ -2018-12-17 dana <dana@dana.is> +2018-12-24 dana <dana@dana.is> + + * 43935 (tweaked): Src/Modules/datetime.c, Test/V09datetime.ztst: + Fix test error on 32-bit machines, reject too-large nanosecond + values given to strftime + +2018-12-23 dana <dana@dana.is> * 43928: Completion/Base/Utility/_alternative: Evaluate (...) action syntax as with _arguments diff --git a/Src/Modules/datetime.c b/Src/Modules/datetime.c index 18c7fb58e..521c15a5b 100644 --- a/Src/Modules/datetime.c +++ b/Src/Modules/datetime.c @@ -148,7 +148,7 @@ output_strftime(char *nam, char **argv, Options ops, UNUSED(int func)) } else if (*argv[2] == '\0' || *endptr != '\0') { zwarnnam(nam, "%s: invalid decimal number", argv[2]); return 1; - } else if (ts.tv_nsec < 0) { + } else if (ts.tv_nsec < 0 || ts.tv_nsec > 999999999) { zwarnnam(nam, "%s: invalid nanosecond value", argv[2]); return 1; } diff --git a/Test/V09datetime.ztst b/Test/V09datetime.ztst index 22d560750..2041d9b40 100644 --- a/Test/V09datetime.ztst +++ b/Test/V09datetime.ztst @@ -90,7 +90,7 @@ strftime '%Y-%m-%d %H:%M:%S.%3.' 1012615322 strftime '%Y-%m-%d %H:%M:%S.%3.' 1012615322 0 strftime '%Y-%m-%d %H:%M:%S.%3.' 1012615322 2 - strftime '%Y-%m-%d %H:%M:%S.%3.' 1012615322 $(( 222 * (10 ** 9) )) + strftime '%Y-%m-%d %H:%M:%S.%3.' 1012615322 $(( 222 * (10 ** 6) )) 0:optional nanoseconds >2002-02-02 02:02:02.000 >2002-02-02 02:02:02.000 @@ -103,6 +103,9 @@ strftime '%Y' 1012615322 '' 2> /dev/null 1:empty nanoseconds not allowed + strftime '%N' 1012615322 $(( 10 ** 9 )) 2> /dev/null +1:too-large nanoseconds not allowed + strftime '%N' 1012615322 ${(l<64><9>):-} 2> /dev/null 1:overflowed nanoseconds not allowed |