Blame time/bug-asctime_r.c

Packit 6c4009
#include <errno.h>
Packit 6c4009
#include <limits.h>
Packit 6c4009
#include <stdio.h>
Packit 6c4009
#include <time.h>
Packit 6c4009
Packit 6c4009
Packit 6c4009
static int
Packit 6c4009
do_test (void)
Packit 6c4009
{
Packit 6c4009
  int result = 0;
Packit 6c4009
  time_t t = time (NULL);
Packit 6c4009
  struct tm *tp = localtime (&t);
Packit 6c4009
  tp->tm_year = 10000 - 1900;
Packit 6c4009
  char buf[1000];
Packit 6c4009
  errno = 0;
Packit 6c4009
  buf[26] = '\xff';
Packit 6c4009
  char *s = asctime_r (tp, buf);
Packit 6c4009
  if (s != NULL || errno != EOVERFLOW)
Packit 6c4009
    {
Packit 6c4009
      puts ("asctime_r did not fail correctly");
Packit 6c4009
      result = 1;
Packit 6c4009
    }
Packit 6c4009
  if (buf[26] != '\xff')
Packit 6c4009
    {
Packit 6c4009
      puts ("asctime_r overwrote 27th byte in buffer");
Packit 6c4009
      result = 1;
Packit 6c4009
    }
Packit 6c4009
  return result;
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
#define TEST_FUNCTION do_test ()
Packit 6c4009
#include "../test-skeleton.c"