From 494a40dfbb174930ca616e560532d52549736b42 Mon Sep 17 00:00:00 2001 From: Olaf Bergmann Date: Thu, 25 Jul 2019 17:27:15 +0200 Subject: [PATCH] dtls.c: Sanity check on CipherSuites length This change fixes a possible integer underflow when iterating through the CipherSuites indicated in the ClientHello message. Fixes https://bugs.eclipse.org/bugs/show_bug.cgi?id=534333 Fixes https://bugs.eclipse.org/bugs/show_bug.cgi?id=544824 Change-Id: Ic14780eb11a24c01d30889e7bb74f2e877bb7faa --- dtls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dtls.c b/dtls.c index 8c4e8bea..dd760ffe 100644 --- a/dtls.c +++ b/dtls.c @@ -1075,7 +1075,7 @@ dtls_update_parameters(dtls_context_t *ctx, data_length -= sizeof(uint16) + i; ok = 0; - while (i && !ok) { + while ((i >= (int)sizeof(uint16)) && !ok) { config->cipher = dtls_uint16_to_int(data); ok = known_cipher(ctx, config->cipher, 0); i -= sizeof(uint16);