From cbd9b4a836d540055c17eceea02af7f9e287e2df Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Mon, 9 Sep 2019 20:48:46 +0700 Subject: Rewrite conditionals to avoid overflow --- crypto/src/crypto/Check.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crypto/src') 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); } } -- cgit 1.5.1