From: John Hodge Date: Tue, 10 Sep 2013 00:32:55 +0000 (+0800) Subject: Modules/Ext2 - Handled zero-sized directory records X-Git-Tag: rel0.15~234 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=1100f7207b40fef763f353d8a0b4c798253cc2d9;p=tpg%2Facess2.git Modules/Ext2 - Handled zero-sized directory records --- diff --git a/KernelLand/Modules/Filesystems/Ext2/dir.c b/KernelLand/Modules/Filesystems/Ext2/dir.c index f04a60cf..3d4d2ad1 100644 --- a/KernelLand/Modules/Filesystems/Ext2/dir.c +++ b/KernelLand/Modules/Filesystems/Ext2/dir.c @@ -68,6 +68,12 @@ int Ext2_ReadDir(tVFS_Node *Node, int Pos, char Dest[FILENAME_MAX]) while(Pos -- && size > 0 && size <= inode->i_size) { VFS_ReadAt( disk->FD, Base+ofs, sizeof(tExt2_DirEnt), &dirent); + + if( dirent.rec_len == 0 ) { + size = 0; + break; + } + ofs += dirent.rec_len; size -= dirent.rec_len; entNum ++; @@ -148,6 +154,8 @@ tVFS_Node *Ext2_FindDir(tVFS_Node *Node, const char *Filename, Uint Flags) // If it matches, create a node and return it if(dirent.name_len == filenameLen && strncmp(dirent.name, Filename, filenameLen) == 0) return Ext2_int_CreateNode( disk, dirent.inode ); + if( dirent.rec_len == 0 ) + break; // Increment pointers ofs += dirent.rec_len; size -= dirent.rec_len; @@ -162,6 +170,8 @@ tVFS_Node *Ext2_FindDir(tVFS_Node *Node, const char *Filename, Uint Flags) } ofs = 0; Base = Ext2_int_GetBlockAddr( disk, inode->i_block, block ); + if( Base == 0 ) + break; } }