Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoao Matos <joao@tritao.eu>2016-10-27 21:12:31 +0300
committerJoao Matos <joao@tritao.eu>2016-10-27 22:44:38 +0300
commit31f8da0b50460075bb381bcb0d9152cc231faba2 (patch)
tree278bce2e25bd79960f2ba58e90cac101ab6dfa9f /mcs/class/System/Test
parent86c24e94279f56d0426924fbb533f14d2c9b41a0 (diff)
[System.IO.Compression] Fixed DeflateStream inflate() decompression loop.
This reworks the fix from https://github.com/mono/mono/commit/7c4d41a518aaf0370b882f9430752ebcd5544c10. That fix introduced a regression when handling some inputs, which lead us to ignore some left-over data from zlib's inflate output buffer. Now we only break from the loop if inflate() returns Z_BUF_ERROR. This makes sure all data is fully processed before returning to managed code. Fixes one of the bugs in https://bugzilla.xamarin.com/show_bug.cgi?id=44994#c2.
Diffstat (limited to 'mcs/class/System/Test')
-rw-r--r--mcs/class/System/Test/System.IO.Compression/DeflateStreamTest.cs21
1 files changed, 21 insertions, 0 deletions
diff --git a/mcs/class/System/Test/System.IO.Compression/DeflateStreamTest.cs b/mcs/class/System/Test/System.IO.Compression/DeflateStreamTest.cs
index 0fe01aaf102..4fef4c5f4d8 100644
--- a/mcs/class/System/Test/System.IO.Compression/DeflateStreamTest.cs
+++ b/mcs/class/System/Test/System.IO.Compression/DeflateStreamTest.cs
@@ -410,6 +410,27 @@ namespace MonoTests.System.IO.Compression
using (var unZippedStream = new StreamReader (gZipStream, Encoding.UTF8)) {
unZipped = unZippedStream.ReadToEnd ();
}
+
+ Assert.AreEqual(1877, unZipped.Length);
+ }
+
+ [Test]
+ public void Bug44994_Inflate()
+ {
+ var base64String = @"7cWxCQAgDACwpeBjgqsgXiHU0fd9QzBLErX1EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADepcxcuU/atm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm3btm37zy8=";
+
+ byte[] byteArray = Convert.FromBase64String(base64String);
+ string unZipped = null;
+
+ using (var zippedMemoryStream = new MemoryStream(byteArray))
+ using (var gZipStream = new DeflateStream(zippedMemoryStream, CompressionMode.Decompress))
+ using (var unzippedMemStream = new MemoryStream())
+ using (var unZippedStream = new StreamReader(gZipStream, Encoding.UTF8))
+ {
+ unZipped = unZippedStream.ReadToEnd();
+ }
+
+ Assert.AreEqual(81942, unZipped.Length);
}
}
}