Skip to content

Commit ddcc45b

Browse files
committed
dtls.c: Fix handling ClientHello if no peer and fragment
If a fragmented ClientHello is received with no peer, do not handle it. Signed-off-by: Jon Shallow <supjps-libcoap@jpshallow.com>
1 parent 94205ff commit ddcc45b

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

dtls.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3676,6 +3676,11 @@ handle_handshake(dtls_context_t *ctx, dtls_peer_t *peer, session_t *session,
36763676
size_t fragment_offset = dtls_uint24_to_int(hs_header->fragment_offset);
36773677

36783678
if (packet_length > fragment_length){
3679+
if (!peer || !peer->handshake_params) {
3680+
/* This is the initial ClientHello */
3681+
dtls_alert("Cannot handle fragmented ClientHello\n");
3682+
return dtls_alert_fatal_create(DTLS_ALERT_HANDSHAKE_FAILURE);
3683+
}
36793684
dtls_debug("received fragmented handshake packet: length %zu, fragment length %zu.\n",
36803685
packet_length, fragment_length);
36813686
/* If (reassembled) packet is larger than our buffer, drop with error */

0 commit comments

Comments
 (0)