Fix extfs symbolic link access and truncation bugs.
This commit is contained in:
parent
00f9af4bf3
commit
231f73c4f9
|
@ -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
|
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
|
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();
|
inode->Unref();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
memcpy(dest, dest_raw, msg->namelen);
|
memcpy(dest, dest_raw, msg->targetlen);
|
||||||
dest[msg->targetlen] = '\0';
|
dest[msg->targetlen] = '\0';
|
||||||
|
|
||||||
char* path_raw = (char*) dest_raw + msg->targetlen;
|
char* path_raw = (char*) dest_raw + msg->targetlen;
|
||||||
|
|
|
@ -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
|
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
|
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();
|
block->Unref();
|
||||||
if ( flags & O_EXCL )
|
if ( flags & O_EXCL )
|
||||||
return errno = EEXIST, (Inode*) NULL;
|
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;
|
return errno = EEXIST, (Inode*) NULL;
|
||||||
Inode* inode = filesystem->GetInode(inode_id);
|
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();
|
inode->Unref();
|
||||||
return errno = EEXIST, (Inode*) NULL;
|
return errno = EEXIST, (Inode*) NULL;
|
||||||
|
|
Loading…
Reference in New Issue