bug-asctime.c 623 B

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