runtime: Zip package becomes corrupted (CRC error)

Refer to https://github.com/OfficeDev/Open-XML-SDK/issues/506

This is an issue I first discovered in dealing with OpenXml and it seems the root cause is a bug in System.IO.Packaging.

Description

Using System.IO.Packaging to purely open and save a file (without any manipulation) causes a corrupt zip package. 7-Zip says there is a CRC error: image

This subsequently means that Excel 2013 complains that the xlsx file is corrupt.

Note that the file contains custom property parts, some of which are of 0 lengths. I don’t have control of those parts.

This problem occurs only when using .NET Core, not with .NET Framework.

Information

  • .NET Target: .NET Core 2.0
  • System.IO.Packaging Version: v.4.5.0

Repro

using System;
using System.IO;
using System.IO.Packaging;

namespace OpenXMLCustomPropertyPackagingProblemCore
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            File.Copy("test.xlsx", "file_to_open.xlsx", true);
            using (var package = Package.Open("file_to_open.xlsx", FileMode.Open))
            {
            }

            Console.WriteLine("Done.");
            Console.ReadKey(false);
        }
    }
}

Files

MD5 hashes:

94db2b0108899c032526987091eaea6f *file_to_open.xlsx
ac39d841fc15384c252c4870063f9b54 *test.xlsx

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 17 (10 by maintainers)

Commits related to this issue

Most upvoted comments

Sorry to be the guy who does unnecessary poking, but has anyone perhaps started looking at this?