X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Fvfs%2Fopen.c;h=6f0341706e7d5fe3100a78ef1ec5c7a26009cee6;hb=9d3800f60f2212432e550a4e003ae65b498a4d36;hp=0494294db84c9bac4882d8d87d6fc85de33074d4;hpb=51adc08a1e11fe9e5389e6e7c3e3a4ea4973917b;p=tpg%2Facess2.git diff --git a/Kernel/vfs/open.c b/Kernel/vfs/open.c index 0494294d..6f034170 100644 --- a/Kernel/vfs/open.c +++ b/Kernel/vfs/open.c @@ -61,7 +61,13 @@ char *VFS_GetAbsPath(char *Path) } strcpy(ret, Path); } else { - cwdLen = strlen(cwd); + if(cwd == NULL) { + cwd = "/"; + cwdLen = 1; + } + else { + cwdLen = strlen(cwd); + } endLen = cwdLen + pathLen + 2; // Prepend the current directory ret = malloc(endLen); @@ -119,6 +125,7 @@ char *VFS_GetAbsPath(char *Path) write += (pos-read)+1; } + ret[write] = '\0'; // Cap string (to deal with . or .. being the last terms) // `ret` should now be the absolute path LEAVE('s', ret); //Log("VFS_GetAbsPath: RETURN '%s'", ret); @@ -534,7 +541,8 @@ int VFS_ChDir(char *New) VFS_Close(fd); // Free old working directory - if( CFGPTR(CFG_VFS_CWD) ) free( CFGPTR(CFG_VFS_CWD) ); + if( CFGPTR(CFG_VFS_CWD) ) + free( CFGPTR(CFG_VFS_CWD) ); // Set new CFGPTR(CFG_VFS_CWD) = buf;