Back to index

glibc  2.9
Defines | Functions
bug-asctime_r.c File Reference
#include <errno.h>
#include <limits.h>
#include <stdio.h>
#include <time.h>
#include "../test-skeleton.c"

Go to the source code of this file.

Defines

#define TEST_FUNCTION   do_test ()

Functions

static int do_test (void)

Define Documentation

#define TEST_FUNCTION   do_test ()

Definition at line 31 of file bug-asctime_r.c.


Function Documentation

static int do_test ( void  ) [static]

Definition at line 8 of file bug-asctime_r.c.

{
  int result = 0;
  time_t t = time (NULL);
  struct tm *tp = localtime (&t);
  tp->tm_year = 10000 - 1900;
  char buf[1000];
  errno = 0;
  buf[26] = '\xff';
  char *s = asctime_r (tp, buf);
  if (s != NULL || errno != EOVERFLOW)
    {
      puts ("asctime_r did not fail correctly");
      result = 1;
    }
  if (buf[26] != '\xff')
    {
      puts ("asctime_r overwrote 27th byte in buffer");
      result = 1;
    }
  return result;
}

Here is the call graph for this function: