added sanity check on return from recv callback

This commit is contained in:
John Safranek 2013-01-24 14:44:08 -08:00
parent 6616975f81
commit b17b81ef43
2 changed files with 8 additions and 0 deletions

View File

@ -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 */

View File

@ -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);
}