From 3cd64581ebe87aec0f08563d11c51f311d781aee Mon Sep 17 00:00:00 2001 From: Juliusz Sosinowicz Date: Thu, 30 Jan 2025 18:02:34 +0100 Subject: [PATCH] dtls: better sanitize incoming messages in stateless handling --- src/dtls.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/dtls.c b/src/dtls.c index a0ba10e84..d5b8b0d4e 100644 --- a/src/dtls.c +++ b/src/dtls.c @@ -365,7 +365,8 @@ static int FindExtByType(WolfSSL_ConstVector* ret, word16 extType, ato16(exts.elements + idx, &type); idx += OPAQUE16_LEN; idx += ReadVector16(exts.elements + idx, &ext); - if (idx > exts.size) + if (idx > exts.size || + ext.elements + ext.size > exts.elements + exts.size) return BUFFER_ERROR; if (type == extType) { XMEMCPY(ret, &ext, sizeof(ext)); @@ -498,7 +499,7 @@ static int TlsCheckSupportedVersion(const WOLFSSL* ssl, ch->extension, &tlsxFound); if (ret != 0) return ret; - if (!tlsxFound) { + if (!tlsxFound || tlsxSupportedVersions.elements == NULL) { *isTls13 = 0; return 0; }