You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 7, 2023. It is now read-only.
I found that the method CompoundFile.LoadDirectories fail to handle the case where the starting sector of a directory entry is invalid.
With the sample file FTC07.zip, the starting sector of the directory entry #42 is equal to 6553868 which is invalid. Adding the below line to Line 685, we can check directoryEntries[42].StartSetc Console.WriteLine(directoryEntries[42].StartSetc); // 6553868
We should check de.StartSetc in the method CompoundFile.LoadDirectories. If de.StartSetc is greater than this.sectors.Count, we should raise an exception that the file is invalid.
private void LoadDirectories()
{
List<Sector> directoryChain
= GetSectorChain(header.FirstDirectorySectorID, SectorType.Normal);
if (header.FirstDirectorySectorID == Sector.ENDOFCHAIN)
header.FirstDirectorySectorID = directoryChain[0].Id;
StreamView dirReader
= new StreamView(directoryChain, GetSectorSize(), directoryChain.Count * GetSectorSize(), sourceStream);
while (dirReader.Position < directoryChain.Count * GetSectorSize())
{
IDirectoryEntry de
= DirectoryEntry.New(String.Empty, StgType.StgInvalid, directoryEntries);
//We are not inserting dirs. Do not use 'InsertNewDirectoryEntry'
de.Read(dirReader);
// We should check de.StartSetc here
if(de.StartSetc > sectors.Count)
{
throw new CFException("Compound File is invalid");
}
}
}
Sorry for my bad description about the issue.
Best regards,
Nhut M. Ngo
The text was updated successfully, but these errors were encountered:
@nmnhut2010@salaros This project is a old fork of the original OpenMcdf source hosted on sourceforge. I would recommend using and improving the original now, after it also moved to github a while ago: (https://github.com/ironfede/openmcdf).
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I found that the method
CompoundFile.LoadDirectories
fail to handle the case where the starting sector of a directory entry is invalid.With the sample file FTC07.zip, the starting sector of the directory entry #42 is equal to 6553868 which is invalid. Adding the below line to Line 685, we can check
directoryEntries[42].StartSetc
Console.WriteLine(directoryEntries[42].StartSetc); // 6553868
We should check
de.StartSetc
in the methodCompoundFile.LoadDirectories
. Ifde.StartSetc
is greater thanthis.sectors.Count
, we should raise an exception that the file is invalid.Sorry for my bad description about the issue.
Best regards,
Nhut M. Ngo
The text was updated successfully, but these errors were encountered: