X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FModules%2FFilesystems%2FNTFS%2Fmain.c;h=18caf46245a783d7530b6833f14a1f373d915174;hb=13078002b01ee4f63eb2001d2ef479a2a006ea32;hp=3b17e17e13cf9368568f50c2d6328b5d14f55b4c;hpb=e7a76b0d8a0cc6aa77966509780973a6f8216ef7;p=tpg%2Facess2.git diff --git a/KernelLand/Modules/Filesystems/NTFS/main.c b/KernelLand/Modules/Filesystems/NTFS/main.c index 3b17e17e..18caf462 100644 --- a/KernelLand/Modules/Filesystems/NTFS/main.c +++ b/KernelLand/Modules/Filesystems/NTFS/main.c @@ -70,7 +70,11 @@ int NTFS_Detect(int FD) if( bs.BytesPerSector == 0 || (bs.BytesPerSector & 511) ) return 0; - + if( bs.SectorsPerCluster == 0 ) + return 0; + if( bs.ClustersPerMFTRecord == 0 ) + return 0; + Uint64 ncluster = bs.TotalSectorCount / bs.SectorsPerCluster; if( bs.MFTStart >= ncluster || bs.MFTMirrorStart >= ncluster ) return 0; @@ -123,6 +127,7 @@ tVFS_Node *NTFS_InitDevice(const char *Device, const char **Options) #endif disk->ClusterSize = bs.BytesPerSector * bs.SectorsPerCluster; + ASSERTR(disk->ClusterSize > 0, NULL); disk->MFTBase = bs.MFTStart; Log_Debug("NTFS", "Cluster Size = %i KiB", disk->ClusterSize/1024); Log_Debug("NTFS", "MFT Base = %i", disk->MFTBase); @@ -134,6 +139,7 @@ tVFS_Node *NTFS_InitDevice(const char *Device, const char **Options) else { disk->MFTRecSize = bs.ClustersPerMFTRecord * disk->ClusterSize; } + ASSERTR(disk->MFTRecSize > 0, NULL); //NTFS_DumpEntry(disk, 0); // $MFT //NTFS_DumpEntry(disk, 3); // $VOLUME