In DTLS mode, the variable inSz gets set to MAX_MTU in GetInputData(). Then enters a do/while loop. If size > MAX_MTU then multiple reads are required to read the message. In the loop, inSz is decremented to zero after the first read. This will cause the Receive() call to fail.
do
{
in = Receive(ssl, ,, inSz)
ssl->buffers.inputBuffer.length += in;
inSz -= in; <---- inSz = 0, after first read
} while (ssl->buffers.inputBuffer.length < size);
Recommend adding this code before before end of loop
#ifdef CYASSL_DTLS
if (ssl->options.dtls && (ssl->buffers.inputBuffer.length < size))
{
inSz = MIN(size-ssl->buffers.inputBuffer.length, MAX_MTU);
}
#endif