X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FModules%2FFilesystems%2FNTFS%2Fdir.c;h=f72c637c9cd60ca6043538003e6e5351df3e2e53;hb=af67042b8d7f05fe76583aef1afb2022b519a1aa;hp=617d7db36c16fdf3fc86da140329ca9c87102ece;hpb=2c6ec285c9fd7a3034942e724708e2e65d904e4c;p=tpg%2Facess2.git diff --git a/KernelLand/Modules/Filesystems/NTFS/dir.c b/KernelLand/Modules/Filesystems/NTFS/dir.c index 617d7db3..f72c637c 100644 --- a/KernelLand/Modules/Filesystems/NTFS/dir.c +++ b/KernelLand/Modules/Filesystems/NTFS/dir.c @@ -84,8 +84,7 @@ int NTFS_ReadDir(tVFS_Node *Node, int Pos, char Dest[FILENAME_MAX]) vcn ++; } if( !ent ) { - LEAVE('i', 1); - return -1; + LEAVE_RET('i', -1); } // TODO: This is not future-proof @@ -273,6 +272,7 @@ tVFS_Node *NTFS_int_CreateNode(tNTFS_Disk *Disk, Uint64 MFTEntry) ret = &types.tpl_file.Node; ret->Type = &gNTFS_FileType; types.tpl_file.Data = NTFS_GetAttrib(Disk, MFTEntry, NTFS_FileAttrib_Data, "", 0); + ret->Size = types.tpl_file.Data->DataSize; } ret->Inode = MFTEntry; ret->ImplPtr = Disk; @@ -319,8 +319,19 @@ tVFS_Node *NTFS_FindDir(tVFS_Node *Node, const char *Name, Uint Flags) if( len == 0 ) break; tNTFS_IndexHeader *hdr = (void*)buf; + + if( memcmp(&hdr->Magic, "INDX", 4) != 0 ) { + Log_Notice("NTFS", "FindDir %p:%X:%x index magic bad %08x", + disk, Node->Inode, ofs / unit_len, hdr->Magic); + break; + } // Apply update sequence - ASSERT(hdr->UpdateSequenceOfs + 2*hdr->UpdateSequenceSize <= len); + if(hdr->UpdateSequenceOfs + 2*hdr->UpdateSequenceSize > len) { + Log_Notice("NTFS", "FindDir %p:%X:%x index update sequence out of buffer (%x+%x>%x)", + disk, Node->Inode, ofs / unit_len, + hdr->UpdateSequenceOfs, 2*hdr->UpdateSequenceSize, len); + break; + } NTFS_int_ApplyUpdateSequence(buf,len, (void*)(buf+hdr->UpdateSequenceOfs), hdr->UpdateSequenceSize); // Search //mftent = NTFS_BTreeSearch(len, (void*)buf, NTFS_BTreeSearch_CmpI30, name16len*2, name16); @@ -330,7 +341,7 @@ tVFS_Node *NTFS_FindDir(tVFS_Node *Node, const char *Name, Uint Flags) ); } - if( !mftent ) { + if( !mftent || (mftent & (1ULL << 63)) ) { LEAVE('n'); return NULL; }