Back to index

glibc  2.9
bug-asctime_r.c
Go to the documentation of this file.
00001 #include <errno.h>
00002 #include <limits.h>
00003 #include <stdio.h>
00004 #include <time.h>
00005 
00006 
00007 static int
00008 do_test (void)
00009 {
00010   int result = 0;
00011   time_t t = time (NULL);
00012   struct tm *tp = localtime (&t);
00013   tp->tm_year = 10000 - 1900;
00014   char buf[1000];
00015   errno = 0;
00016   buf[26] = '\xff';
00017   char *s = asctime_r (tp, buf);
00018   if (s != NULL || errno != EOVERFLOW)
00019     {
00020       puts ("asctime_r did not fail correctly");
00021       result = 1;
00022     }
00023   if (buf[26] != '\xff')
00024     {
00025       puts ("asctime_r overwrote 27th byte in buffer");
00026       result = 1;
00027     }
00028   return result;
00029 }
00030 
00031 #define TEST_FUNCTION do_test ()
00032 #include "../test-skeleton.c"