question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Malformed zip file generated

See original GitHub issue

Hi,

I’m using salvois/LargeXlsx library for generating Excel files (which are essentialy zip files) that uses this library. When I try to open a generated file in Excel it says that it’s corrupt. If I try to open the file with any unzip tool there are no errors. When I use the built-in ZipArchive class from .NET Core everything works as expected. I’ve dug a little deeper into the files generated by this library and the .NET one I see that every 16 kB I get 5 bytes inputed into the output stream. I don’t know if this is some special marker but Excel doesn’t recognize it and it messes up the content for it i.e. instead of ‘s=“0”’ i have ‘s=“0 ý€”’.

a simple way to reproduce it:

var ms = new MemoryStream();
var zw = new ZipWriter(ms, new ZipWriterOptions(compressionType: CompressionType.Deflate) { DeflateCompressionLevel = CompressionLevel.None });
var payload = new string('\n', 100000);
using (var stream = zw.WriteToStream("test.txt", new ZipWriterEntryOptions()))
using (var streamWriter = new StreamWriter(stream: stream))
{
    streamWriter.Write(value: payload);
}

sequences are at offsets: 38, 32811, 65584,98357

Linking salvois/LargeXlsx#9

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
Eriorcommented, Jun 17, 2022

Thank you, that does make excel unhappy, I will investigate

0reactions
Nanookcommented, Jul 15, 2022

I’m closing this issue after confirming it’s now working.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Analyzing Malformed ZIP Files
My zipdump tool uses Python's ZIP module to analyze ZIP files. ... As this generates an error, we need to take a closer...
Read more >
Zip file is downloaded, but is malformed
This gets the data and pipes it into a local file ( wpi.zip ). When I run this there is no error and...
Read more >
Malformed zip files #5431 - mysociety/alaveteli
The attached file is one of many zip files generated on the site www.righttoknow.org.au (which is based on (https://alaveteli.org).
Read more >
[Resolved] The user form zip is malformed
I want to export locally created user forms and import them on the staging system. The export works ok. I get a .xml.zip...
Read more >
Office: About OLE and ZIP Files
A reader asked if a particular Emotet sample was a malformed ZIP file. ... file created with Office contains an embedded ZIP file...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found