summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2012-07-04 12:58:07 +0200
committerJim Meyering <meyering@redhat.com>2012-07-04 12:58:07 +0200
commitd8f90adf5f01512958b6da46bd5eea01294a434e (patch)
treea893b72d7893ad2b063b9be0a2774d6ff8ba0679 /tests
parentd0ea2a12f6fb377f930886d404f3dfc2a732537d (diff)
downloadgnulib-d8f90adf5f01512958b6da46bd5eea01294a434e.tar.gz
parse-datetime: fix failure to diagnose invalid input
date -d "$(printf '\xb0')" would print 00:00:00 with today's date rather than diagnosing the invalid input. Now it reports this: date: invalid date '\260' * lib/parse-datetime.y (to_uchar): Define. (yylex): Don't sign-extend "other" bytes. * m4/parse-datetime.m4: Require AC_C_INLINE for first use of "inline". Thanks to Bruno Haible for the patch to this file. * tests/test-parse-datetime.c (main): Add a test to trigger the bug. Peter Evans reported the bug in GNU date: http://bugs.gnu.org/11843
Diffstat (limited to 'tests')
-rw-r--r--tests/test-parse-datetime.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/test-parse-datetime.c b/tests/test-parse-datetime.c
index 4c0370d293..1c9fd2dbd2 100644
--- a/tests/test-parse-datetime.c
+++ b/tests/test-parse-datetime.c
@@ -409,5 +409,9 @@ main (int argc _GL_UNUSED, char **argv)
ASSERT (result.tv_sec == 24 * 3600
&& result.tv_nsec == now.tv_nsec);
+ /* Exercise a sign-extension bug. Before July 2012, an input
+ starting with a high-bit-set byte would be treated like "0". */
+ ASSERT ( ! parse_datetime (&result, "\xb0", &now));
+
return 0;
}