revert defragment of handshake messages in TLS
This commit is contained in:
parent
329e6a6207
commit
6d21d328fb
@ -1941,10 +1941,6 @@ void FreeArrays(WOLFSSL* ssl, int keep)
|
||||
XMEMCPY(ssl->session.sessionID, ssl->arrays->sessionID, ID_LEN);
|
||||
ssl->session.sessionIDSz = ssl->arrays->sessionIDSz;
|
||||
}
|
||||
if (ssl->arrays) {
|
||||
XFREE(ssl->arrays->pendingMsg, ssl->heap, DYNAMIC_TYPE_ARRAYS);
|
||||
ssl->arrays->pendingMsg = NULL;
|
||||
}
|
||||
XFREE(ssl->arrays, ssl->heap, DYNAMIC_TYPE_CERT);
|
||||
ssl->arrays = NULL;
|
||||
}
|
||||
@ -5243,65 +5239,16 @@ static int DoHandShakeMsgType(WOLFSSL* ssl, byte* input, word32* inOutIdx,
|
||||
static int DoHandShakeMsg(WOLFSSL* ssl, byte* input, word32* inOutIdx,
|
||||
word32 totalSz)
|
||||
{
|
||||
byte type;
|
||||
word32 size;
|
||||
int ret = 0;
|
||||
|
||||
WOLFSSL_ENTER("DoHandShakeMsg()");
|
||||
|
||||
/* If there is a pending fragmented handshake message, pending message size
|
||||
* will be non-zero. */
|
||||
if (ssl->arrays->pendingMsgSz == 0) {
|
||||
byte type;
|
||||
word32 size;
|
||||
if (GetHandShakeHeader(ssl, input, inOutIdx, &type, &size, totalSz) != 0)
|
||||
return PARSE_ERROR;
|
||||
|
||||
if (GetHandShakeHeader(ssl,input, inOutIdx, &type, &size, totalSz) != 0)
|
||||
return PARSE_ERROR;
|
||||
|
||||
/* size is the size of the certificate message payload */
|
||||
if (totalSz - HANDSHAKE_HEADER_SZ < size) {
|
||||
ssl->arrays->pendingMsgType = type;
|
||||
ssl->arrays->pendingMsgSz = size + HANDSHAKE_HEADER_SZ;
|
||||
ssl->arrays->pendingMsg = (byte*)XMALLOC(size + HANDSHAKE_HEADER_SZ,
|
||||
ssl->heap,
|
||||
DYNAMIC_TYPE_ARRAYS);
|
||||
if (ssl->arrays->pendingMsg == NULL)
|
||||
return MEMORY_E;
|
||||
XMEMCPY(ssl->arrays->pendingMsg,
|
||||
input + *inOutIdx - HANDSHAKE_HEADER_SZ, totalSz);
|
||||
ssl->arrays->pendingMsgOffset = totalSz;
|
||||
*inOutIdx += totalSz - HANDSHAKE_HEADER_SZ;
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = DoHandShakeMsgType(ssl, input, inOutIdx, type, size, totalSz);
|
||||
}
|
||||
else {
|
||||
if (totalSz + ssl->arrays->pendingMsgOffset
|
||||
> ssl->arrays->pendingMsgSz) {
|
||||
|
||||
return BUFFER_ERROR;
|
||||
}
|
||||
else {
|
||||
XMEMCPY(ssl->arrays->pendingMsg + ssl->arrays->pendingMsgOffset,
|
||||
input + *inOutIdx, totalSz);
|
||||
ssl->arrays->pendingMsgOffset += totalSz;
|
||||
*inOutIdx += totalSz;
|
||||
}
|
||||
|
||||
if (ssl->arrays->pendingMsgOffset == ssl->arrays->pendingMsgSz)
|
||||
{
|
||||
word32 idx = 0;
|
||||
ret = DoHandShakeMsgType(ssl,
|
||||
ssl->arrays->pendingMsg
|
||||
+ HANDSHAKE_HEADER_SZ,
|
||||
&idx, ssl->arrays->pendingMsgType,
|
||||
ssl->arrays->pendingMsgSz
|
||||
- HANDSHAKE_HEADER_SZ,
|
||||
ssl->arrays->pendingMsgSz);
|
||||
XFREE(ssl->arrays->pendingMsg, ssl->heap, DYNAMIC_TYPE_ARRAYS);
|
||||
ssl->arrays->pendingMsg = NULL;
|
||||
ssl->arrays->pendingMsgSz = 0;
|
||||
}
|
||||
}
|
||||
ret = DoHandShakeMsgType(ssl, input, inOutIdx, type, size, totalSz);
|
||||
|
||||
WOLFSSL_LEAVE("DoHandShakeMsg()", ret);
|
||||
return ret;
|
||||
|
@ -2081,10 +2081,7 @@ typedef struct Options {
|
||||
} Options;
|
||||
|
||||
typedef struct Arrays {
|
||||
byte* pendingMsg; /* defrag buffer */
|
||||
word32 preMasterSz; /* differs for DH, actual size */
|
||||
word32 pendingMsgSz; /* defrag buffer size */
|
||||
word32 pendingMsgOffset; /* current offset into defrag buffer */
|
||||
#ifndef NO_PSK
|
||||
word32 psk_keySz; /* acutal size */
|
||||
char client_identity[MAX_PSK_ID_LEN];
|
||||
|
Loading…
x
Reference in New Issue
Block a user