summary refs log tree commit diff
path: root/crypto
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2019-09-09 20:48:46 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2019-09-09 20:48:46 +0700
commitcbd9b4a836d540055c17eceea02af7f9e287e2df (patch)
tree6252db271ecb8bd193f009a118ab1eb0c2906dda /crypto
parentSupport user cancellation of (D)TLS handshakes (diff)
downloadBouncyCastle.NET-ed25519-cbd9b4a836d540055c17eceea02af7f9e287e2df.tar.xz
Rewrite conditionals to avoid overflow
Diffstat (limited to 'crypto')
-rw-r--r--crypto/src/crypto/Check.cs4
1 files changed, 2 insertions, 2 deletions
diff --git a/crypto/src/crypto/Check.cs b/crypto/src/crypto/Check.cs
index 96a05c64b..aacda144f 100644
--- a/crypto/src/crypto/Check.cs
+++ b/crypto/src/crypto/Check.cs
@@ -12,13 +12,13 @@ namespace Org.BouncyCastle.Crypto
 
         internal static void DataLength(byte[] buf, int off, int len, string msg)
         {
-            if (off + len > buf.Length)
+            if (off > (buf.Length - len))
                 throw new DataLengthException(msg);
         }
 
         internal static void OutputLength(byte[] buf, int off, int len, string msg)
         {
-            if (off + len > buf.Length)
+            if (off > (buf.Length - len))
                 throw new OutputLengthException(msg);
         }
     }