diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2019-09-09 20:48:46 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2019-09-09 20:48:46 +0700 |
commit | cbd9b4a836d540055c17eceea02af7f9e287e2df (patch) | |
tree | 6252db271ecb8bd193f009a118ab1eb0c2906dda | |
parent | Support user cancellation of (D)TLS handshakes (diff) | |
download | BouncyCastle.NET-ed25519-cbd9b4a836d540055c17eceea02af7f9e287e2df.tar.xz |
Rewrite conditionals to avoid overflow
-rw-r--r-- | crypto/src/crypto/Check.cs | 4 |
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); } } |