Topic: DTLS crash after timeout (patch)
We have had problems with wolfSSL embedded ssl 2.6 crashing after negotiations fail. It turns out that it tried to free a buffer that was never malloced, and I traced the problem to DtlsPoolSend. It should call CheckAvalaibleSize() [sic], shouldn't it?
The below patch (on wolfssl-2.6.0) appears to solve the problem. Looking at the code, building without LARGE_STATIC_BUFFERS (which is what I do) makes things worse.
Index: cyassl/src/internal.c
===================================================================
--- cyassl.orig/src/internal.c 2013-05-08 15:22:15.704663345 +0200
+++ cyassl/src/internal.c 2013-05-08 15:24:14.716658339 +0200
@@ -1791,6 +1791,7 @@
int DtlsPoolSend(CYASSL* ssl)
{
+ int ret;
DtlsPool *pool = ssl->dtls_pool;
if (pool != NULL && pool->used > 0) {
@@ -1807,6 +1808,9 @@
c16toa(ssl->keys.dtls_epoch, dtls->epoch);
c32to48(ssl->keys.dtls_sequence_number++, dtls->sequence_number);
+ if ((ret = CheckAvalaibleSize(ssl, buf->length)) != 0)
+ return ret;
+
XMEMCPY(ssl->buffers.outputBuffer.buffer, buf->buffer, buf->length);
ssl->buffers.outputBuffer.idx = 0;
ssl->buffers.outputBuffer.length = buf->length;