bug-asctime_r.c 756 B

12345678910111213141516171819202122232425262728293031323334353637
  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 = 10000 - 1900;
  16. char buf[1000];
  17. errno = 0;
  18. buf[26] = '\xff';
  19. char *s = asctime_r (tp, buf);
  20. if (s != NULL || errno != EOVERFLOW)
  21. {
  22. puts ("asctime_r did not fail correctly");
  23. result = 1;
  24. }
  25. if (buf[26] != '\xff')
  26. {
  27. puts ("asctime_r overwrote 27th byte in buffer");
  28. result = 1;
  29. }
  30. return result;
  31. }
  32. #define TEST_FUNCTION do_test ()
  33. #include "../test-skeleton.c"