Skip to content

Commit 612e9f7

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 612e9f7

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
@@ -3436,6 +3436,11 @@ check_server_certificate(dtls_context_t *ctx,
34363436

34373437
data += DTLS_HS_LENGTH;
34383438

3439+
if (data_length < DTLS_HS_LENGTH + DTLS_EC_SUBJECTPUBLICKEY_SIZE + sizeof(uint24)) {
3440+
dtls_alert("the packet length does not match the expected\n");
3441+
return dtls_alert_fatal_create(DTLS_ALERT_DECODE_ERROR);
3442+
}
3443+
34393444
if (dtls_uint24_to_int(data) != DTLS_EC_SUBJECTPUBLICKEY_SIZE) {
34403445
dtls_alert("expect length of %zu bytes for certificate\n",
34413446
DTLS_EC_SUBJECTPUBLICKEY_SIZE);

0 commit comments

Comments
 (0)