From 3d91a55b882bd0183a4aa29190556f4bb8de85f0 Mon Sep 17 00:00:00 2001 From: toddouska Date: Fri, 1 Jun 2012 15:37:51 -0700 Subject: [PATCH] tls sanity check --- src/tls.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/tls.c b/src/tls.c index dfeab8147..447f0d819 100644 --- a/src/tls.c +++ b/src/tls.c @@ -33,6 +33,16 @@ #ifndef NO_TLS +#ifndef min + + static INLINE word32 min(word32 a, word32 b) + { + return a > b ? b : a; + } + +#endif /* min */ + + /* calculate XOR for TLSv1 PRF */ static INLINE void get_xor(byte *digest, word32 digLen, byte* md5, byte* sha) { @@ -74,7 +84,7 @@ static void p_hash(byte* result, word32 resLen, const byte* secret, HmacFinal(&hmac, current); if ( (i == lastTime) && lastLen) - XMEMCPY(&result[idx], current, lastLen); + XMEMCPY(&result[idx], current, min(lastLen, sizeof(current))); else { XMEMCPY(&result[idx], current, len); idx += len;