Check for buffer overrun
authorGabriel Garcia <garciat@live.com>
Sun, 5 Apr 2015 15:41:36 +0000 (11:41 -0400)
committerGabriel Garcia <garciat@live.com>
Sun, 5 Apr 2015 15:41:36 +0000 (11:41 -0400)
mcs/class/System/System.IO.Compression/DeflateStream.cs

index 939a0c9b5403474434ff85c9468b65a7c865d9d0..f416df5f99420dc80db0bcd427168f13f1f277a3 100644 (file)
@@ -171,6 +171,9 @@ namespace System.IO.Compression
                        if (!CanWrite)
                                throw new NotSupportedException ("Stream does not support writing");
 
+                       if (count + src_offset > src.Length)
+                               throw new ArgumentException ("Buffer too small. count/offset wrong.");
+
                        WriteInternal (src, src_offset, count);
                }