Skip to content
Snippets Groups Projects
Commit f669c5be authored by John Hodge's avatar John Hodge
Browse files

Kernel - Fixed a bug in VFS_ParsePath that cause symlinks to break

parent bd2f2872
Branches
Tags
No related merge requests found
...@@ -495,6 +495,7 @@ char *strncpy(char *__str1, const char *__str2, size_t max) ...@@ -495,6 +495,7 @@ char *strncpy(char *__str1, const char *__str2, size_t max)
char *strcat(char *__dest, const char *__src) char *strcat(char *__dest, const char *__src)
{ {
while(*__dest++); while(*__dest++);
__dest--;
while(*__src) while(*__src)
*__dest++ = *__src++; *__dest++ = *__src++;
*__dest = '\0'; *__dest = '\0';
......
...@@ -19,7 +19,7 @@ tVFS_Handle *VFS_GetHandle(int FD); ...@@ -19,7 +19,7 @@ tVFS_Handle *VFS_GetHandle(int FD);
int VFS_AllocHandle(int FD, tVFS_Node *Node, int Mode); int VFS_AllocHandle(int FD, tVFS_Node *Node, int Mode);
// === GLOBALS === // === GLOBALS ===
tVFS_Handle *gaUserHandles = (void*)MM_PPD_VFS; tVFS_Handle *gaUserHandles = (void*)MM_PPD_HANDLES;
tVFS_Handle *gaKernelHandles = (void*)MM_KERNEL_VFS; tVFS_Handle *gaKernelHandles = (void*)MM_KERNEL_VFS;
// === CODE === // === CODE ===
......
...@@ -144,6 +144,8 @@ int VFS_Seek(int FD, Sint64 Offset, int Whence) ...@@ -144,6 +144,8 @@ int VFS_Seek(int FD, Sint64 Offset, int Whence)
// Set relative to end of file // Set relative to end of file
if(Whence < 0) { if(Whence < 0) {
if( h->Node->Size == -1 ) return -1;
h->Position = h->Node->Size - Offset; h->Position = h->Node->Size - Offset;
return 0; return 0;
} }
......
...@@ -203,7 +203,7 @@ restart_parse: ...@@ -203,7 +203,7 @@ restart_parse:
// Check if there is anything mounted // Check if there is anything mounted
if(!gVFS_Mounts) { if(!gVFS_Mounts) {
Warning("WTF! There's nothing mounted?"); Log_Error("VFS", "VFS_ParsePath - No filesystems mounted");
return NULL; return NULL;
} }
...@@ -318,7 +318,7 @@ restart_parse: ...@@ -318,7 +318,7 @@ restart_parse:
*TruePath = NULL; *TruePath = NULL;
} }
if(!curNode->Read) { if(!curNode->Read) {
Warning("VFS_ParsePath - Read of node %p is NULL (%s)", Log_Warning("VFS", "VFS_ParsePath - Read of symlink node %p'%s' is NULL",
curNode, Path); curNode, Path);
if(curNode->Close) curNode->Close(curNode); if(curNode->Close) curNode->Close(curNode);
// No need to free *TruePath, it should already be NULL // No need to free *TruePath, it should already be NULL
...@@ -345,12 +345,12 @@ restart_parse: ...@@ -345,12 +345,12 @@ restart_parse:
} }
curNode->Read( curNode, 0, curNode->Size, path_buffer ); curNode->Read( curNode, 0, curNode->Size, path_buffer );
path_buffer[ curNode->Size ] = '\0'; path_buffer[ curNode->Size ] = '\0';
strcat(path_buffer, &Path[ofs+nextSlash]); strcat(path_buffer, Path + ofs+nextSlash);
Path = path_buffer; Path = path_buffer;
// Log_Debug("VFS", "VFS_ParsePath: Symlink translated to '%s'", Path);
iNestedLinks ++; iNestedLinks ++;
} }
// EVIL: Goto :) // EVIL: Goto :)
goto restart_parse; goto restart_parse;
...@@ -359,7 +359,7 @@ restart_parse: ...@@ -359,7 +359,7 @@ restart_parse:
// Handle Non-Directories // Handle Non-Directories
if( !(curNode->Flags & VFS_FFLAG_DIRECTORY) ) if( !(curNode->Flags & VFS_FFLAG_DIRECTORY) )
{ {
Warning("VFS_ParsePath - File in directory context"); Log_Warning("VFS", "VFS_ParsePath - Path segment is not a directory");
if(TruePath) free(*TruePath); if(TruePath) free(*TruePath);
LEAVE('n'); LEAVE('n');
return NULL; return NULL;
...@@ -372,7 +372,7 @@ restart_parse: ...@@ -372,7 +372,7 @@ restart_parse:
tmp = realloc( *TruePath, retLength + strlen(pathEle) + 1 + 1 ); tmp = realloc( *TruePath, retLength + strlen(pathEle) + 1 + 1 );
// Check if allocation succeeded // Check if allocation succeeded
if(!tmp) { if(!tmp) {
Warning("VFS_ParsePath - Unable to reallocate true path buffer"); Log_Warning("VFS", "VFS_ParsePath - Unable to reallocate true path buffer");
free(*TruePath); free(*TruePath);
*TruePath = NULL; *TruePath = NULL;
if(curNode->Close) curNode->Close(curNode); if(curNode->Close) curNode->Close(curNode);
...@@ -396,7 +396,7 @@ restart_parse: ...@@ -396,7 +396,7 @@ restart_parse:
free(*TruePath); free(*TruePath);
*TruePath = NULL; *TruePath = NULL;
} }
Log("FindDir fail on '%s'", Path); Log_Warning("VFS", "VFS_ParsePath - FindDir doesn't exist for element of '%s'", Path);
LEAVE('n'); LEAVE('n');
return NULL; return NULL;
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment