bug-asctime.c 935 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* Note: we disable this on uClibc because we dont bother
  2. * verifying if the year is sane ... we just return ????
  3. * for the year value ...
  4. */
  5. #include <errno.h>
  6. #include <limits.h>
  7. #include <stdio.h>
  8. #include <time.h>
  9. static int
  10. do_test (void)
  11. {
  12. int result = 0;
  13. time_t t = time (NULL);
  14. struct tm *tp = localtime (&t);
  15. tp->tm_year = INT_MAX;
  16. errno = 0;
  17. char *s = asctime (tp);
  18. if (s != NULL || errno != EOVERFLOW)
  19. {
  20. printf ("asctime did not fail correctly: s=%p, wanted %p; errno=%i, wanted %i\n",
  21. s, NULL, errno, EOVERFLOW);
  22. result = 1;
  23. }
  24. char buf[1000];
  25. errno = 0;
  26. s = asctime_r (tp, buf);
  27. if (s != NULL || errno != EOVERFLOW)
  28. {
  29. printf ("asctime_r did not fail correctly: s=%p, wanted %p; errno=%i, wanted %i\n",
  30. s, NULL, errno, EOVERFLOW);
  31. result = 1;
  32. }
  33. return result;
  34. }
  35. #define TEST_FUNCTION do_test ()
  36. #include "../test-skeleton.c"