Skip to content

Commit 32920f9

Browse files
authored
PR #422: Change ZipOutputStream.PutNextEntry to explicity validate the requested compression method
1 parent ca33534 commit 32920f9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/ICSharpCode.SharpZipLib/Zip/ZipOutputStream.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ private void WriteLeLong(long value)
206206
/// Entry name is too long<br/>
207207
/// Finish has already been called<br/>
208208
/// </exception>
209+
/// <exception cref="System.NotImplementedException">
210+
/// The Compression method specified for the entry is unsupported.
211+
/// </exception>
209212
public void PutNextEntry(ZipEntry entry)
210213
{
211214
if (entry == null)
@@ -229,6 +232,13 @@ public void PutNextEntry(ZipEntry entry)
229232
}
230233

231234
CompressionMethod method = entry.CompressionMethod;
235+
236+
// Check that the compression is one that we support
237+
if (method != CompressionMethod.Deflated && method != CompressionMethod.Stored)
238+
{
239+
throw new NotImplementedException("Compression method not supported");
240+
}
241+
232242
int compressionLevel = defaultCompressionLevel;
233243

234244
// Clear flags that the library manages internally

0 commit comments

Comments
 (0)