1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00

Fix extfs symbolic link access and truncation bugs.

This commit is contained in:
Jonas 'Sortie' Termansen 2015-01-29 21:06:31 +01:00
parent 00f9af4bf3
commit 231f73c4f9
2 changed files with 10 additions and 5 deletions

View file

@ -1,6 +1,6 @@
/*******************************************************************************
Copyright(C) Jonas 'Sortie' Termansen 2013, 2014.
Copyright(C) Jonas 'Sortie' Termansen 2013, 2014, 2015.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
@ -600,7 +600,7 @@ void HandleSymlink(int chl, struct fsm_req_symlink* msg, Filesystem* fs)
inode->Unref();
return;
}
memcpy(dest, dest_raw, msg->namelen);
memcpy(dest, dest_raw, msg->targetlen);
dest[msg->targetlen] = '\0';
char* path_raw = (char*) dest_raw + msg->targetlen;

View file

@ -1,6 +1,6 @@
/*******************************************************************************
Copyright(C) Jonas 'Sortie' Termansen 2013.
Copyright(C) Jonas 'Sortie' Termansen 2013, 2014, 2015.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
@ -389,10 +389,15 @@ Inode* Inode::Open(const char* elem, int flags, mode_t mode)
block->Unref();
if ( flags & O_EXCL )
return errno = EEXIST, (Inode*) NULL;
if ( flags & O_DIRECTORY && file_type && file_type != EXT2_FT_DIR )
if ( (flags & O_DIRECTORY) &&
file_type != EXT2_FT_UNKNOWN &&
file_type != EXT2_FT_DIR &&
file_type != EXT2_FT_SYMLINK )
return errno = EEXIST, (Inode*) NULL;
Inode* inode = filesystem->GetInode(inode_id);
if ( flags & O_DIRECTORY && !EXT2_S_ISDIR(inode->Mode()) )
if ( flags & O_DIRECTORY &&
!EXT2_S_ISDIR(inode->Mode()) &&
!EXT2_S_ISLNK(inode->Mode()) )
{
inode->Unref();
return errno = EEXIST, (Inode*) NULL;