Protect against overflow
authorGabriel Garcia <garciat@live.com>
Sun, 5 Apr 2015 21:11:01 +0000 (17:11 -0400)
committerGabriel Garcia <garciat@live.com>
Sun, 5 Apr 2015 21:11:01 +0000 (17:11 -0400)
https://github.com/mono/mono/pull/1682#commitcomment-10578913

mcs/class/System/System.IO.Compression/DeflateStream.cs

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