diff options
author | Ulrich Drepper <drepper@redhat.com> | 2005-10-14 14:10:20 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2005-10-14 14:10:20 +0000 |
commit | 576c8451485408d776914e756e5cc554e9d93eda (patch) | |
tree | 36c76940f6aaea04798eac3d55d4684bca69662e /time/bug-asctime.c | |
parent | 93c6cb8b8d5c48944c82243b82713e97fd13dc17 (diff) | |
download | glibc-576c8451485408d776914e756e5cc554e9d93eda.tar glibc-576c8451485408d776914e756e5cc554e9d93eda.tar.gz glibc-576c8451485408d776914e756e5cc554e9d93eda.tar.bz2 glibc-576c8451485408d776914e756e5cc554e9d93eda.zip |
[BZ #1459]
* time/asctime.c (__asctime_r): Check for tm_year computation to
overflow and fail in this case.
* time/Makefile (tests): Add bug-asctime.
* time/bug-asctime.c: New file.
Diffstat (limited to 'time/bug-asctime.c')
-rw-r--r-- | time/bug-asctime.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/time/bug-asctime.c b/time/bug-asctime.c new file mode 100644 index 0000000000..7204e1b2fe --- /dev/null +++ b/time/bug-asctime.c @@ -0,0 +1,32 @@ +#include <errno.h> +#include <limits.h> +#include <stdio.h> +#include <time.h> + + +static int +do_test (void) +{ + int result = 0; + time_t t = time (NULL); + struct tm *tp = localtime (&t); + tp->tm_year = INT_MAX; + errno = 0; + char *s = asctime (tp); + if (s != NULL || errno != EOVERFLOW) + { + puts ("asctime did not fail correctly"); + result = 1; + } + char buf[1000]; + s = asctime_r (tp, buf); + if (s != NULL || errno != EOVERFLOW) + { + puts ("asctime_r did not fail correctly"); + result = 1; + } + return result; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" |