mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 10:47:28 +02:00
Merge pull request #5246 from rizlik/dtls_header_fixes
dtls: handshake header parsing fixes
This commit is contained in:
@ -15027,6 +15027,12 @@ static int DoDtlsHandShakeMsg(WOLFSSL* ssl, byte* input, word32* inOutIdx,
|
|||||||
return INCOMPLETE_DATA;
|
return INCOMPLETE_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* check that the fragment is contained in the message */
|
||||||
|
if (fragOffset + fragSz > size) {
|
||||||
|
WOLFSSL_ERROR(LENGTH_ERROR);
|
||||||
|
return LENGTH_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if (type == finished && ssl->keys.dtls_peer_handshake_number >=
|
if (type == finished && ssl->keys.dtls_peer_handshake_number >=
|
||||||
ssl->keys.dtls_expected_peer_handshake_number &&
|
ssl->keys.dtls_expected_peer_handshake_number &&
|
||||||
ssl->keys.curEpoch == ssl->keys.dtls_epoch) {
|
ssl->keys.curEpoch == ssl->keys.dtls_epoch) {
|
||||||
@ -15099,7 +15105,17 @@ static int DoDtlsHandShakeMsg(WOLFSSL* ssl, byte* input, word32* inOutIdx,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ret = DoHandShakeMsgType(ssl, input, inOutIdx, type, size, totalSz);
|
if (fragSz < size) {
|
||||||
|
/* a fragmented ClientHello, very probably forged or
|
||||||
|
erroneous. Even if the packet is valid, we don't want to save
|
||||||
|
state while processing a ClientHello to avoid DoS attacks */
|
||||||
|
WOLFSSL_MSG("Ignoring datagram with fragmented ClientHello");
|
||||||
|
*inOutIdx = totalSz;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ret = DoHandShakeMsgType(ssl, input, inOutIdx, type, size,
|
||||||
|
totalSz);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (ssl->keys.dtls_peer_handshake_number <
|
else if (ssl->keys.dtls_peer_handshake_number <
|
||||||
@ -15142,6 +15158,13 @@ static int DoDtlsHandShakeMsg(WOLFSSL* ssl, byte* input, word32* inOutIdx,
|
|||||||
* be pointing to the message with this fragment in it. Check it to see
|
* be pointing to the message with this fragment in it. Check it to see
|
||||||
* if it is completed. */
|
* if it is completed. */
|
||||||
WOLFSSL_MSG("Branch is in order, but fragmented");
|
WOLFSSL_MSG("Branch is in order, but fragmented");
|
||||||
|
|
||||||
|
if (type == client_hello) {
|
||||||
|
WOLFSSL_MSG("Ignoring datagram with fragmented ClientHello");
|
||||||
|
*inOutIdx = totalSz;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (ssl->dtls_rx_msg_list_sz < DTLS_POOL_SZ) {
|
if (ssl->dtls_rx_msg_list_sz < DTLS_POOL_SZ) {
|
||||||
DtlsMsgStore(ssl, ssl->keys.curEpoch,
|
DtlsMsgStore(ssl, ssl->keys.curEpoch,
|
||||||
ssl->keys.dtls_peer_handshake_number,
|
ssl->keys.dtls_peer_handshake_number,
|
||||||
|
Reference in New Issue
Block a user