Code Monkey home page Code Monkey logo

openmcdf's Introduction

CodeCavePro

openmcdf's People

Contributors

salaros avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

openmcdf's Issues

Large memory consumption

Hi
I tried to unpack a large msdf file (about 500 Mb) and got large memory consumption (about 6-8 Gb).
I think what this because a new byte[] operation take place many times.

Can you made some changes like this:
Sector.cs - add function

       public void GetData(byte[] buffer, int offset, int length)
        {
            if (IsStreamed)
            {
                stream.Seek((long)size + (long)this.id * (long)size, SeekOrigin.Begin);
                stream.Read(buffer, offset, Math.Min(size, length));
            }
        }

And use it at the StreamView.cs (function int Read(byte[] buffer, int offset, int count)) instead of sectorChain[secIndex].GetData() function

Thanks

ArgumentOutOfRangeException

I got an ArgumentOutOfRangeException when run this code

        static void Main(string[] args)
        {
            var file = new CompoundFile(@"cf_test6.bin");
            var cfStream = file.RootStorage.TryGetStorage("Layer2").TryGetStream("ids");

            // ArgumentOutOfRangeException
            var r = new StreamReader(cfStream.AsIOStream());
            // If replace by this code line, no exception
            //var r = new StreamReader(new MemoryStream(cfStream.GetData()));
            int count = 0;
            while (r.ReadLine() != null)
            {
                count++;
            }
            Console.WriteLine(count);

            Console.ReadLine();
        }

cf_test6.bin

Loading an invalid compound document file

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

Compound File limit size to 268434944 bytes?

I can't create a compound file more than 268434944 bytes. I got StackOverflow exception when try to do this.
SectorCollection.cs has a line
private const int MAX_SECTOR_V4_COUNT_LOCK_RANGE = 524287; //0x7FFFFF00 for Version 4
This is limited max file size to 524287*512 = 268434944 bytes.
What is wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.