Back to index

glibc  2.9
realpath_chk.c File Reference
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

Go to the source code of this file.


char * __realpath_chk (const char *buf, char *resolved, size_t resolvedlen)

Function Documentation

char* __realpath_chk ( const char *  buf,
char *  resolved,
size_t  resolvedlen 

Definition at line 26 of file realpath_chk.c.

#ifdef PATH_MAX
  if (resolvedlen < PATH_MAX)
    __chk_fail ();

  return __realpath (buf, resolved);
  long int pathmax =__pathconf (buf, _PC_PATH_MAX);
  if (pathmax != -1)
      /* We do have a fixed limit.  */
      if (resolvedlen < pathmax)
       __chk_fail ();

      return __realpath (buf, resolved);

  /* Since there is no fixed limit we check whether the size is large
     enough.  */
  char *res = __realpath (buf, NULL);
  if (res != NULL)
      size_t actlen = strlen (res) + 1;
      if (actlen > resolvedlen)
       __chk_fail ();

      memcpy (resolved, res, actlen);
      free (res);
      res = resolved;

  return res;

Here is the call graph for this function: