Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

fixing ZipPackagePart.GetStreamCore crashes with NotSupportedException #40355

Merged
merged 1 commit into from
Aug 15, 2019

Conversation

stevenbrix
Copy link
Contributor

@stevenbrix stevenbrix commented Aug 15, 2019

Port #40319 to release/3.0
Fixes https://github.com/dotnet/corefx/issues/39816

Description

When trying to extract the stream from a PackagePart in Create mode, PackagePart.GetStream unnecessarily throws an exception because the stream is not seekable. The underlying ZipArchiveEntry only ever supports opening once when the backing archive is in Create mode, so we shouldn't call SetLength in that case. You could still open an archive in `Update mode then call part.GetStream(FileMode.Create), in which case we'll want this call to SetLength, so we only avoid this call when the backing Archive is in Create mode.

Customer Impact

This is a behavioral change between the old .NET Framework implementation of System.IO.Packaging that resided in WindowsBase, and the implementation in .NET Core. Customers trying to update their existing WPF applications will be broken by this. This issue was originally filed due to a regression it caused in WPF: dotnet/wpf#1363

Regression?

This is a regression from .NET Framework, but has been the behavior in .NET Core since 1.0.

Risk

Very low. The fix avoids an unnecessary call to SetLength on a non-seekable stream.

ZipArchiveEntry only ever supports opening once when the backing archive is in Create mode,  and the backing stream is non-seekable, so we shouldn't call SetLength in that case. You could still open an archive in Update mode then call part.GetStream(FileMode.Create), in which case we'll want this call to SetLength, so we only avoid this call when the backing Archive is in Create mode.

updating test to explicitly test the Update path for ZipPackage

skip UAP since we don't have access to the file system to create the .zip

undo accidental change to existing test

removing unnecessary variable
@eerhardt
Copy link
Member

This was approved in shiproom today. Feel free to merge it when ready.

@stevenbrix stevenbrix merged commit 75ec1b3 into release/3.0 Aug 15, 2019
Anipik pushed a commit that referenced this pull request Aug 15, 2019
* [release/3.0]Handle `UnparseableExtension` status code when building X509Chain on … (#40117)

Ignore `UnparseableExtension` status code when building X509Chain on OSX

* [release/3.0] Update dependencies from 3 repositories (#40308)

* Update dependencies from https://github.com/dotnet/core-setup build 20190814.02

- Microsoft.NETCore.App - 3.0.0-preview9-19414-02
- Microsoft.NETCore.DotNetHostPolicy - 3.0.0-preview9-19414-02
- Microsoft.NETCore.DotNetHost - 3.0.0-preview9-19414-02

* Update dependencies from https://github.com/dotnet/arcade build 20190812.7

- Microsoft.DotNet.XUnitExtensions - 2.4.1-beta.19412.7
- Microsoft.DotNet.XUnitConsoleRunner - 2.5.1-beta.19412.7
- Microsoft.DotNet.VersionTools.Tasks - 1.0.0-beta.19412.7
- Microsoft.DotNet.ApiCompat - 1.0.0-beta.19412.7
- Microsoft.DotNet.Arcade.Sdk - 1.0.0-beta.19412.7
- Microsoft.DotNet.Build.Tasks.Configuration - 1.0.0-beta.19412.7
- Microsoft.DotNet.Build.Tasks.Feed - 2.2.0-beta.19412.7
- Microsoft.DotNet.Build.Tasks.Packaging - 1.0.0-beta.19412.7
- Microsoft.DotNet.CodeAnalysis - 1.0.0-beta.19412.7
- Microsoft.DotNet.CoreFxTesting - 1.0.0-beta.19412.7
- Microsoft.DotNet.GenAPI - 1.0.0-beta.19412.7
- Microsoft.DotNet.GenFacades - 1.0.0-beta.19412.7
- Microsoft.DotNet.Helix.Sdk - 2.0.0-beta.19412.7
- Microsoft.DotNet.RemoteExecutor - 1.0.0-beta.19412.7

* Update dependencies from https://github.com/dotnet/standard build 20190814.3

- NETStandard.Library - 2.1.0-prerelease.19414.3

* fixing ZipPackagePart.GetStreamCore crashes with NotSupportedException (#40355)

ZipArchiveEntry only ever supports opening once when the backing archive is in Create mode,  and the backing stream is non-seekable, so we shouldn't call SetLength in that case. You could still open an archive in Update mode then call part.GetStream(FileMode.Create), in which case we'll want this call to SetLength, so we only avoid this call when the backing Archive is in Create mode.

updating test to explicitly test the Update path for ZipPackage

skip UAP since we don't have access to the file system to create the .zip

undo accidental change to existing test

removing unnecessary variable

* Support custom converters that treat non-null input as null (#40287) (#40357)
@jkotas jkotas deleted the dev/stevenbrix/port-40319 branch August 19, 2019 12:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants