From 059db7f69c5763b2c9ba12fd590865e2b1c3063a Mon Sep 17 00:00:00 2001 From: John Safranek Date: Tue, 18 Sep 2012 16:00:30 -0700 Subject: [PATCH 1/2] check the return code of DtlsPoolSave() --- src/internal.c | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/src/internal.c b/src/internal.c index f3ccc42d7..7038ad0a4 100644 --- a/src/internal.c +++ b/src/internal.c @@ -1283,7 +1283,7 @@ int DtlsPoolSave(CYASSL* ssl, const byte *src, int sz) pBuf->buffer = (byte*)XMALLOC(sz, ssl->heap, DYNAMIC_TYPE_OUT_BUFFER); if (pBuf->buffer == NULL) { CYASSL_MSG("DTLS Buffer Memory error"); - return MEMORY_E; + return MEMORY_ERROR; } XMEMCPY(pBuf->buffer, src, sz); pBuf->length = (word32)sz; @@ -3316,7 +3316,8 @@ int SendChangeCipher(CYASSL* ssl) #ifdef CYASSL_DTLS if (ssl->options.dtls) { - DtlsPoolSave(ssl, output, sendSz); + if ((ret = DtlsPoolSave(ssl, output, sendSz)) != 0) + return ret; } #endif #ifdef CYASSL_CALLBACKS @@ -3520,7 +3521,9 @@ static int BuildMessage(CYASSL* ssl, byte* output, const byte* input, int inSz, if (type == handshake) { #ifdef CYASSL_DTLS if (ssl->options.dtls) { - DtlsPoolSave(ssl, output, headerSz+inSz); + int ret; + if ((ret = DtlsPoolSave(ssl, output, headerSz+inSz)) != 0) + return ret; } #endif HashOutput(ssl, output, headerSz + inSz, ivSz); @@ -3596,7 +3599,8 @@ int SendFinished(CYASSL* ssl) } #ifdef CYASSL_DTLS if (ssl->options.dtls) { - DtlsPoolSave(ssl, output, sendSz); + if ((ret = DtlsPoolSave(ssl, output, sendSz)) != 0) + return ret; } #endif @@ -3679,7 +3683,8 @@ int SendCertificate(CYASSL* ssl) } #ifdef CYASSL_DTLS if (ssl->options.dtls) { - DtlsPoolSave(ssl, output, sendSz); + if ((ret = DtlsPoolSave(ssl, output, sendSz)) != 0) + return ret; } #endif HashOutput(ssl, output, sendSz, 0); @@ -3753,7 +3758,8 @@ int SendCertificateRequest(CYASSL* ssl) #ifdef CYASSL_DTLS if (ssl->options.dtls) { - DtlsPoolSave(ssl, output, sendSz); + if ((ret = DtlsPoolSave(ssl, output, sendSz)) != 0) + return ret; } #endif HashOutput(ssl, output, sendSz, 0); @@ -5023,7 +5029,8 @@ int SetCipherList(Suites* s, const char* list) #ifdef CYASSL_DTLS if (ssl->options.dtls) { - DtlsPoolSave(ssl, output, sendSz); + if ((ret = DtlsPoolSave(ssl, output, sendSz)) != 0) + return ret; } #endif HashOutput(ssl, output, sendSz, 0); @@ -5631,7 +5638,8 @@ int SetCipherList(Suites* s, const char* list) idx += encSz; */ #ifdef CYASSL_DTLS if (ssl->options.dtls) { - DtlsPoolSave(ssl, output, sendSz); + if ((ret = DtlsPoolSave(ssl, output, sendSz)) != 0) + return ret; } #endif HashOutput(ssl, output, sendSz, 0); @@ -5771,7 +5779,8 @@ int SetCipherList(Suites* s, const char* list) #ifdef CYASSL_DTLS if (ssl->options.dtls) { sendSz += DTLS_RECORD_EXTRA + DTLS_HANDSHAKE_EXTRA; - DtlsPoolSave(ssl, output, sendSz); + if ((ret = DtlsPoolSave(ssl, output, sendSz)) != 0) + return ret; } #endif HashOutput(ssl, output, sendSz, 0); @@ -5877,7 +5886,8 @@ int SetCipherList(Suites* s, const char* list) ssl->buffers.outputBuffer.length += sendSz; #ifdef CYASSL_DTLS if (ssl->options.dtls) { - DtlsPoolSave(ssl, output, sendSz); + if ((ret = DtlsPoolSave(ssl, output, sendSz)) != 0) + return ret; } #endif HashOutput(ssl, output, sendSz, 0); @@ -6342,7 +6352,8 @@ int SetCipherList(Suites* s, const char* list) #ifdef CYASSL_DTLS if (ssl->options.dtls) { - DtlsPoolSave(ssl, output, sendSz); + if ((ret = DtlsPoolSave(ssl, output, sendSz)) != 0) + return ret; } #endif HashOutput(ssl, output, sendSz, 0); @@ -7199,7 +7210,8 @@ int SetCipherList(Suites* s, const char* list) #ifdef CYASSL_DTLS if (ssl->options.dtls) { - DtlsPoolSave(ssl, output, sendSz); + if ((ret = DtlsPoolSave(ssl, output, sendSz)) != 0) + return 0; } #endif HashOutput(ssl, output, sendSz, 0); From 08a3423f43913fb5d390822902f527adaab24fec Mon Sep 17 00:00:00 2001 From: John Safranek Date: Wed, 19 Sep 2012 09:09:27 -0700 Subject: [PATCH 2/2] changed error return code for dtls functions to NOT_COMPILED_IN --- src/ssl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ssl.c b/src/ssl.c index 26cc47d7c..428eecea8 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -2244,7 +2244,7 @@ int CyaSSL_dtls_get_current_timeout(CYASSL* ssl) #ifdef CYASSL_DTLS return ssl->dtls_timeout; #else - return SSL_NOT_IMPLEMENTED; + return NOT_COMPILED_IN; #endif } @@ -2259,7 +2259,7 @@ int CyaSSL_dtls_got_timeout(CYASSL* ssl) return result; #else (void)ssl; - return SSL_NOT_IMPLEMENTED; + return NOT_COMPILED_IN; #endif }