Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexOutOfRangeException in System.IO.Compression.ZipArchive #109167

Closed
peter15914 opened this issue Oct 23, 2024 · 1 comment · Fixed by #109168
Closed

IndexOutOfRangeException in System.IO.Compression.ZipArchive #109167

peter15914 opened this issue Oct 23, 2024 · 1 comment · Fixed by #109168
Assignees
Labels
area-System.IO.Compression bug in-pr There is an active PR which will close this issue when it is merged
Milestone

Comments

@peter15914
Copy link
Contributor

Description

An IndexOutOfRangeException exception is thrown when invalid zip file is opened with ZipArchive.

Reproduction Steps

using System.IO.Compression;

Stream file = File.OpenRead("ZipArchive_IndexOutOfRangeException_001.zip");
MemoryStream stream = new MemoryStream();
file.CopyTo(stream);

using var archive = new ZipArchive(stream, ZipArchiveMode.Read);
foreach (var entry in archive.Entries)
{
    using var source = entry.Open();
    using var destination = new MemoryStream();
    source.CopyTo(destination);
}

With "ZipArchive_IndexOutOfRangeException_001.zip" index is invalid in HuffmanTree.c:260:
array[index] = (short)ch;

With "ZipArchive_IndexOutOfRangeException_002.zip" index is invalid in HuffmanTree.c:220:
short value = array[index];

ZipArchive_IndexOutOfRangeException_001.zip
ZipArchive_IndexOutOfRangeException_002.zip

Expected behavior

InvalidDataException is thrown.

Actual behavior

IndexOutOfRangeException is thrown.

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Oct 23, 2024
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-io-compression
See info in area-owners.md if you want to be subscribed.

@dotnet-policy-service dotnet-policy-service bot added the in-pr There is an active PR which will close this issue when it is merged label Oct 23, 2024
peter15914 added a commit to peter15914/runtime-assets that referenced this issue Nov 20, 2024
An IndexOutOfRangeException exception is thrown when this invalid zip file is opened with ZipArchive.
This file is generated while fuzzing ZipArchive with AFL++.

More details in issue and pull request:
dotnet/runtime#109167
dotnet/runtime#109168
akoeplinger pushed a commit to dotnet/runtime-assets that referenced this issue Nov 21, 2024
An IndexOutOfRangeException exception is thrown when this invalid zip file is opened with ZipArchive.
This file is generated while fuzzing ZipArchive with AFL++.

More details in issue and pull request:
dotnet/runtime#109167
dotnet/runtime#109168
@ericstj ericstj removed the untriaged New issue has not been triaged by the area owner label Dec 17, 2024
@ericstj ericstj added this to the 10.0.0 milestone Dec 17, 2024
@ericstj ericstj added the bug label Dec 17, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Feb 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.IO.Compression bug in-pr There is an active PR which will close this issue when it is merged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants