Skip to content

XLSX files above 16MB are rejected #176

Description

@james-francis-advanced

Hello,

We're currently seeing an issue where XLSX files above 16MB are failing the content check, despite the file being seemingly valid and the start bytes matching the ZIP format (50 4B 03 04). Excel also opens the files without any error.

Claude suggests the following - I don't know enough about the file byte checking to know if this is accurate though, apologies if it is not.

The file is a perfectly valid XLSX — it starts with PK\x03\x04 and the tail is a standard ZIP EOCD record. The problem is a bug in MagicBytesValidator v2.1.6: Zip.EndsWith encodes a 22-byte EOCD pattern with a hardcoded 0x00 at byte offset 19, which is the most significant byte of the 4-byte central directory offset field. This file is 19MB so its central directory starts at 0x0126BCBC — that MSB is 0x01, not 0x00, so the check fails. Any ZIP-based file (XLSX, DOCX, PPTX, ODS, ODT, ODP) whose central directory sits beyond ~16.7MB into the file will hit this.

I realise this references v2.1.6 as this is the version we are using (for .NET 8 compatibility) but the problem seems to still exist in v2.2.1.

Thanks!

Metadata

Metadata

Assignees

Labels

.NETPull requests that update .NET codebugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions