char *realpath(char const *pathname , char *result , char *chroot_path ) { char curpath[256] ; char workpath[256] ; char linkpath[256] ; char namebuf[256] ; char *where ; int len ; int tmp ; char *__retres ; {where = curpath; tmp = nondet_int(); if (tmp == 1) {len = readlink((char const *)(namebuf), linkpath, 256); if (len <= 0) {__retres = (char *)((void *)0); goto return_label;} /* STAC: BAD */ linkpath[len] = (char)0; if ((int )linkpath[0] == '/') {workpath[0] = (char)0;} if ((int )*(where + 0) != 0) {r_strcat(linkpath, "/"); r_strcat(linkpath, where);} /* STAC: BAD */ r_strcpy(curpath, linkpath);} __retres = result; return_label: /* CIL Label */ return (__retres);} }
char *fb_realpath(char const *path , char *resolved ) { int rootd ; char wbuf[256] ; char *tmp_0 ; int tmp_1 ; int tmp_2 ; char *__retres ; {wbuf[256 - 1] = (char)0; tmp_0 = getcwd(resolved, 256); if (tmp_0 == (void *)0) {__retres = (char *)((void *)0); goto return_label;} if ((int )*(resolved + 0) == '/') {if ((int )*(resolved + 1) == 0) {rootd = 1;} else {rootd = 0;} } else {rootd = 0;} if ((int )wbuf[0] != 0) {{tmp_1 = strlen(resolved); tmp_2 = strlen(wbuf); } if (((tmp_1 + tmp_2) + rootd) + 1 > 256) {__retres = (char *)((void *)0); goto return_label;} if (rootd == 0) {strcat(resolved, "/");} r_strcat(resolved, wbuf);} __retres = (char *)((void *)0); return_label: /* CIL Label */ return (__retres);} }
/* resolved is an *input*, initially uninitialized */ char *fb_realpath(const char *path, char *resolved) { int rootd; char wbuf[MAXPATHLEN]; int resultcode; char tmp [MAXPATHLEN]; int p, q; (void) strncpy(resolved, path, MAXPATHLEN - 1); resolved[MAXPATHLEN - 1] = EOS; /* Once this loop terminates, the final slash in resolved has been * replaced with an EOS, and p points to the filename after it. */ q = istrrchr(resolved, '/'); if (q != -1) { /* p is whatever's after the last slash */ p = q + 1; } else /* no slashes found ==> just a filename */ p = 0; /* wbuf contains the filename, but not the path to it */ strcpy(wbuf, resolved + p); if (getcwd(resolved, MAXPATHLEN) == NULL) return NULL; if (resolved[0] == '/' && resolved[1] == EOS) rootd = 1; else rootd = 0; if (wbuf[0] != EOS) { if (strlen(resolved) + strlen(wbuf) + !rootd + 1 > MAXPATHLEN) { return NULL; } if (rootd == 0) (void) strcat(resolved, "/"); /* OK */ (void) r_strcat(resolved, wbuf); } return (NULL); }
/* resolved is an *input*, initially uninitialized */ char *fb_realpath(const char *path, char *resolved) { int rootd; char wbuf[MAXPATHLEN]; int resultcode; char tmp [MAXPATHLEN]; int p, q; (void) strncpy(resolved, path, MAXPATHLEN - 1); resolved[MAXPATHLEN - 1] = EOS; p = 0; /* wbuf contains the filename, but not the path to it */ strcpy(wbuf, resolved + p); if (getcwd(resolved, MAXPATHLEN) == NULL) return NULL; if (resolved[0] == '/' && resolved[1] == EOS) rootd = 1; else rootd = 0; if (wbuf[0] != EOS) { if (strlen(resolved) + strlen(wbuf) + rootd + 1 > MAXPATHLEN) { return NULL; } if (rootd == 0) (void) strcat(resolved, "/"); /* BAD */ (void) r_strcat(resolved, wbuf); } return (NULL); }
char * realpath(const char *pathname, char *result, char* chroot_path) { char curpath[MAXPATHLEN], workpath[MAXPATHLEN], namebuf[MAXPATHLEN]; if (result == NULL) return(NULL); if(pathname == NULL){ *result = EOS; return(NULL); } workpath[MAXPATHLEN-1] = EOS; strcpy(curpath, pathname); strcpy(namebuf, workpath); /* BAD */ r_strcat(namebuf, curpath); return result; }
char *realpath(char const *pathname , char *result , char *chroot_path ) { char curpath[256] ; char workpath[256] ; char namebuf[256] ; int where ; int last ; uid_t userid ; char *tmp ; char *tmp_0 ; int tmp_1 ; char *__retres ; {if (result == (void *)0) {__retres = (char *)((void *)0); goto return_label;} if (pathname == (void *)0) {*result = (char)0; __retres = (char *)((void *)0); goto return_label;} strcpy(curpath, pathname); if ((int const )*(pathname + 0) != '/') {tmp_0 = getcwd(workpath, 256); if (! tmp_0) {userid = geteuid(); delay_signaling(); seteuid((short)0); tmp = getcwd(workpath, 256); if (! tmp) {strcpy(result, "."); seteuid(userid); enable_signaling(); __retres = (char *)((void *)0); goto return_label;} seteuid(userid); enable_signaling();} } else {workpath[0] = (char)0;} where = 0; while ((int )curpath[where] != 0) {tmp_1 = strcmp(curpath + where, "."); if (! tmp_1) {where ++; continue;} /* STAC: BAD */ strcpy(namebuf, workpath); last = 0; while ((int )namebuf[last] != 0) {goto __Cont; __Cont: /* CIL Label */ ; last ++;} if (last == 0) {r_strcat(namebuf, "/");} else {{last --; } if ((int )namebuf[last] != '/') {r_strcat(namebuf, "/");} } /* STAC: BAD */ r_strcat(namebuf, curpath + where);} __retres = result; return_label: /* CIL Label */ return (__retres);} }
char * realpath(const char *pathname, char *result, char* chroot_path) { char curpath[MAXPATHLEN], workpath[MAXPATHLEN], linkpath[MAXPATHLEN], namebuf[MAXPATHLEN]; int len; int where; int ptr; int last; if (result == NULL) return(NULL); if(pathname == NULL){ *result = EOS; return(NULL); } strcpy(curpath, pathname); if (pathname[0] != '/') { uid_t userid; if (!getcwd(workpath,MAXPATHLEN)) { userid = geteuid(); delay_signaling(); seteuid(0); if (!getcwd(workpath,MAXPATHLEN)) { strcpy(result, "."); seteuid(userid); enable_signaling(); return (NULL); } seteuid(userid); enable_signaling(); } } else workpath[0] = EOS; where = 0; while (curpath[where] != EOS) { if (!strcmp(curpath + where, ".")) { where++; continue; } strcpy(namebuf, workpath); for (last = 0; namebuf[last] != EOS; last++) continue; /* Chop out the out-of-bounds writes.... */ } /* Stand-in for checking stat fields. */ if (nondet_int() == 1) { len = readlink(namebuf, linkpath, MAXPATHLEN); if (len <= 0) return NULL; linkpath[len] = EOS; if (linkpath[0] == '/') workpath[0] = EOS; if (curpath[where] != EOS) { /* BAD */ r_strcat(linkpath, "/"); /* BAD */ r_strcat(linkpath, curpath + where); } /* BAD */ r_strcpy(curpath, linkpath); } return result; }
/* resolved is an *input*, initially uninitialized */ char *fb_realpath(const char *path, char *resolved) { int rootd; char wbuf[MAXPATHLEN]; int resultcode; char tmp [MAXPATHLEN]; int p, q; (void) strncpy(resolved, path, MAXPATHLEN - 1); resolved[MAXPATHLEN - 1] = EOS; /* Once this loop terminates, the final slash in resolved has been * replaced with an EOS, and p points to the filename after it. */ q = istrrchr(resolved, '/'); if (q != -1) { /* p is whatever's after the last slash */ p = q + 1; if (q == 0) { /* Don't do anything. Originally, q was a pointer, we set it * to "/", and chdir'd to "/". Since we're chopping out the chdir, * we don't need to do anything. */ } else { /* chops off the last slash and terminates resolved[] at it */ do { --q; } while (q > 0 && resolved[q] == '/'); resolved[q+1] = EOS; q = 0; } } else /* no slashes found ==> just a filename */ p = 0; /* wbuf contains the filename, but not the path to it */ strcpy(wbuf, resolved + p); if (getcwd(resolved, MAXPATHLEN) == NULL) return NULL; if (resolved[0] == '/' && resolved[1] == EOS) rootd = 1; else rootd = 0; if (wbuf[0] != EOS) { if (strlen(resolved) + strlen(wbuf) + !rootd + 1 > MAXPATHLEN) { return NULL; } if (rootd == 0) (void) strcat(resolved, "/"); /* OK */ (void) r_strcat(resolved, wbuf); } return (NULL); }