]> git.ipfire.org Git - thirdparty/glibc.git/blob - time/bug-asctime.c
[BZ #1459]
[thirdparty/glibc.git] / time / bug-asctime.c
1 #include <errno.h>
2 #include <limits.h>
3 #include <stdio.h>
4 #include <time.h>
5
6
7 static int
8 do_test (void)
9 {
10 int result = 0;
11 time_t t = time (NULL);
12 struct tm *tp = localtime (&t);
13 tp->tm_year = INT_MAX;
14 errno = 0;
15 char *s = asctime (tp);
16 if (s != NULL || errno != EOVERFLOW)
17 {
18 puts ("asctime did not fail correctly");
19 result = 1;
20 }
21 char buf[1000];
22 s = asctime_r (tp, buf);
23 if (s != NULL || errno != EOVERFLOW)
24 {
25 puts ("asctime_r did not fail correctly");
26 result = 1;
27 }
28 return result;
29 }
30
31 #define TEST_FUNCTION do_test ()
32 #include "../test-skeleton.c"