示例#1
0
int main() {
  char path[MAXPATHLEN];
  char resolved[MAXPATHLEN];

  char * ret = fb_realpath(path, resolved);

}
int main(void) 
{ char pathname[256] ;
  char resolved[256] ;
  int __retres ;
  
  {pathname[256 - 1] = (char)0;
  resolved[256 - 1] = (char)0;
  fb_realpath((char const   *)(pathname), resolved);
  __retres = 0;
  return (__retres);}

}
int main ()
{
  char pathname [MAXPATHLEN];
  char resolved [MAXPATHLEN];

  pathname [MAXPATHLEN-1] = EOS;
  resolved [MAXPATHLEN-1] = EOS;

  fb_realpath(pathname, resolved);

  return 0;
}
示例#4
0
char *wu_realpath(const char *path, char resolved_path[MAXPATHLEN], char *chroot_path)
{
    char *ptr;
    char q[MAXPATHLEN];
 
    fb_realpath(path, q);  /* call to fb_realpath is made */

    printf("strlen(q) = %d\n", strlen(q));
    printf("q[MAXPATHLEN - 1] = %c\n",q[MAXPATHLEN - 1]);     

    if (chroot_path == NULL)
        strcpy(resolved_path, q);
    else {
        strcpy(resolved_path, chroot_path);
        if (q[0] != '/') {
            if (strlen(resolved_path) + strlen(q) < MAXPATHLEN)
                strcat(resolved_path, q);
            else                /* Avoid buffer overruns... */
                return NULL;
        }
        else if (q[1] != '\0') {
            for (ptr = q; *ptr != '\0'; ptr++);
            if (ptr == resolved_path || *--ptr != '/') {
                if (strlen(resolved_path) + strlen(q) < MAXPATHLEN)
                    strcat(resolved_path, q);
                else            /* Avoid buffer overruns... */
                    return NULL;
            }
            else {
                if (strlen(resolved_path) + strlen(q) - 1 < MAXPATHLEN)
                    strcat(resolved_path, &q[1]);
                else            /* Avoid buffer overruns... */
                    return NULL;
            }
        }
    }

    return resolved_path;
}
示例#5
0
char *wu_realpath(const char *path, char resolved_path[MAXPATHLEN], char *chroot_path)
{
  char *ptr;
  char q[MAXPATHLEN];

  fb_realpath(path, q);

  if (chroot_path == NULL)
    strcpy(resolved_path, q);
  else {
    strcpy(resolved_path, chroot_path);
    if (q[0] != '/') {
      if (strlen(resolved_path) + strlen(q) < MAXPATHLEN)
	strcat(resolved_path, q);
      else		/* Avoid buffer overruns... */
	return NULL;
    }
    else if (q[1] != '\0') {
      ptr = q;
      while (*ptr != '\0') ptr++;
      if (ptr == resolved_path || *--ptr != '/') {
	if (strlen(resolved_path) + strlen(q) < MAXPATHLEN)
	  strcat(resolved_path, q);
	else		/* Avoid buffer overruns... */
	  return NULL;
      }
      else {
	if (strlen(resolved_path) + strlen(q) - 1 < MAXPATHLEN)
	  strcat(resolved_path, &q[1]);
	else		/* Avoid buffer overruns... */
	  return NULL;
      }
    }
  }
  return resolved_path;
}
示例#6
0
int main() {
  char resolved[MAXPATHLEN];
//  resolved[0] = '\0';
  fb_realpath(resolved);

}