Skip to content

Add strict validation to System.IO.Compression.GZipStream #47563

Closed
@mfkl

Description

@mfkl

EDIT:

This turned out to be handled as a bug rather than an API proposal, see #47563 (comment) for details.

Original description:

Background and Motivation

The System.IO.Compression.GZipStream implemention over zlib does not currently do strict native error reporting.

See https://stackoverflow.com/questions/9456563/gzipstream-doesnt-detect-corrupt-data-even-crc32-passes for more info.

Other zlib managed implementation or bindings over the native API do report issues on corrupt data.

Proposed API

Add a new GZipStream contructor overload.

namespace System.IO.Compression.cs
{
+            public GZipStream(System.IO.Stream stream, System.IO.Compression.CompressionMode mode, bool leaveOpen, bool strictValidation) { }
}

Usage Examples

new GZipStream(decomStream, CompressionMode.Decompress, false, strictValidation: true)

#47560

Alternative Designs

There may better ways to expose this optional behavior. Ideas are welcome.

Risks

Since this is explicitly opt-in, and that the current behavior is not changed, I don't expect any breaking changes or behavior with existing code calling into this API.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions