From b17b81ef43d6e464d7aa6c6311025dd29c88905f Mon Sep 17 00:00:00 2001 From: John Safranek Date: Thu, 24 Jan 2013 14:44:08 -0800 Subject: [PATCH] added sanity check on return from recv callback --- cyassl/error.h | 1 + src/internal.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/cyassl/error.h b/cyassl/error.h index e46fed4e5..6d20030a8 100644 --- a/cyassl/error.h +++ b/cyassl/error.h @@ -108,6 +108,7 @@ enum CyaSSL_ErrorCodes { OUT_OF_ORDER_E = -273, /* out of order message */ BAD_KEA_TYPE_E = -274, /* bad KEA type found */ SANITY_CIPHER_E = -275, /* sanity check on cipher error */ + RECV_OVERFLOW_E = -276, /* RXCB returned more than rqed */ /* add strings to SetErrorString !!!!! */ /* begin negotiation parameter errors */ diff --git a/src/internal.c b/src/internal.c index f4c34a648..df4faca0b 100644 --- a/src/internal.c +++ b/src/internal.c @@ -3856,6 +3856,9 @@ static int GetInputData(CYASSL *ssl, word32 size) if (in == WANT_READ) return WANT_READ; + + if (in > inSz) + return RECV_OVERFLOW_E; ssl->buffers.inputBuffer.length += in; inSz -= in; @@ -5177,6 +5180,10 @@ void SetErrorString(int error, char* str) XSTRNCPY(str, "Sanity check on ciphertext failed", max); break; + case RECV_OVERFLOW_E: + XSTRNCPY(str, "Receive callback returned more than requested", max); + break; + default : XSTRNCPY(str, "unknown error number", max); }