From 38f916a798c3c0592bdca296855248d5eea19a68 Mon Sep 17 00:00:00 2001 From: Jacob Barthelmeh Date: Mon, 18 Jun 2018 15:50:44 -0600 Subject: [PATCH] sanity check on hashing size --- src/internal.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/internal.c b/src/internal.c index 739c730b0..574040b77 100644 --- a/src/internal.c +++ b/src/internal.c @@ -12242,6 +12242,11 @@ static INLINE int VerifyMac(WOLFSSL* ssl, const byte* input, word32 msgSz, padByte = 1; if (ssl->options.tls) { + /* Sanity check for underflow, TimingPadVerify performs hash on size + * (msgSz - ivExtra) - digestSz - pad - 1 */ + if (digestSz + pad + 1 > (msgSz - ivExtra)) { + return BUFFER_E; + } ret = TimingPadVerify(ssl, input, pad, digestSz, msgSz - ivExtra, content); if (ret != 0)