(it could be bypassed by using ..)
char *cwd = CFGPTR(CFG_VFS_CWD);
int cwdLen;
char *cwd = CFGPTR(CFG_VFS_CWD);
int cwdLen;
ENTER("sPath", Path);
// Memory File
ENTER("sPath", Path);
// Memory File
if( chroot == NULL ) {
chroot = "";
chrootLen = 0;
if( chroot == NULL ) {
chroot = "";
chrootLen = 0;
// Check if the path is already absolute
if(Path[0] == '/') {
// Check if the path is already absolute
if(Path[0] == '/') {
- ret = malloc(chrootLen + pathLen + 1);
+ ret = malloc(pathLen + 1);
if(!ret) {
Warning("VFS_GetAbsPath - malloc() returned NULL");
return NULL;
}
if(!ret) {
Warning("VFS_GetAbsPath - malloc() returned NULL");
return NULL;
}
- strcpy(ret, chroot);
- strcpy(ret+chrootLen, Path);
} else {
if(cwd == NULL) {
cwd = "/";
} else {
if(cwd == NULL) {
cwd = "/";
+
+ // Prepend the chroot
+ tmpStr = malloc(chrootLen + strlen(ret) + 1);
+ strcpy( tmpStr, chroot );
+ strcpy( tmpStr+chrootLen, ret );
+ free(ret);
+ ret = tmpStr;
+
LEAVE('s', ret);
//Log("VFS_GetAbsPath: RETURN '%s'", ret);
return ret;
LEAVE('s', ret);
//Log("VFS_GetAbsPath: RETURN '%s'", ret);
return ret;