Skip to content

Commit 3894c78

Browse files
committed
dtls.c: fix length check in check_server_certificate.
Fixes potential out-of-bounds read. Signed-off-by: Achim Kraus <achim.kraus@cloudcoap.net>
1 parent 8a9e048 commit 3894c78

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
@@ -3430,6 +3430,11 @@ check_server_certificate(dtls_context_t *ctx,
34303430
int err;
34313431
dtls_handshake_parameters_t *config = peer->handshake_params;
34323432

3433+
if (data_length < DTLS_HS_LENGTH + DTLS_EC_SUBJECTPUBLICKEY_SIZE + sizeof(uint24)) {
3434+
dtls_alert("the packet length does not match the expected\n");
3435+
return dtls_alert_fatal_create(DTLS_ALERT_DECODE_ERROR);
3436+
}
3437+
34333438
update_hs_hash(peer, data, data_length);
34343439

34353440
assert(is_key_exchange_ecdhe_ecdsa(config->cipher_index));

0 commit comments

Comments
 (0)