Skip to content

Commit

Permalink
PR #422: Change ZipOutputStream.PutNextEntry to explicity validate th…
Browse files Browse the repository at this point in the history
…e requested compression method
  • Loading branch information
Numpsy authored Jun 19, 2020
1 parent ca33534 commit 32920f9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/ICSharpCode.SharpZipLib/Zip/ZipOutputStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ private void WriteLeLong(long value)
/// Entry name is too long<br/>
/// Finish has already been called<br/>
/// </exception>
/// <exception cref="System.NotImplementedException">
/// The Compression method specified for the entry is unsupported.
/// </exception>
public void PutNextEntry(ZipEntry entry)
{
if (entry == null)
Expand All @@ -229,6 +232,13 @@ public void PutNextEntry(ZipEntry entry)
}

CompressionMethod method = entry.CompressionMethod;

// Check that the compression is one that we support
if (method != CompressionMethod.Deflated && method != CompressionMethod.Stored)
{
throw new NotImplementedException("Compression method not supported");
}

int compressionLevel = defaultCompressionLevel;

// Clear flags that the library manages internally
Expand Down

0 comments on commit 32920f9

Please sign in to comment.