From 930e1ac4737906b9444e7f9c7578adfbc805a9aa Mon Sep 17 00:00:00 2001 From: Kareem Date: Wed, 17 Nov 2021 13:54:02 -0700 Subject: [PATCH] Check ssl->arrays in SendClientHello to avoid null dereference. Allow building with fallthrough defined. --- src/internal.c | 4 ++++ wolfssl/wolfcrypt/types.h | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/internal.c b/src/internal.c index aca6eff7a..16d112d81 100644 --- a/src/internal.c +++ b/src/internal.c @@ -22666,6 +22666,10 @@ exit_dpk: WOLFSSL_START(WC_FUNC_CLIENT_HELLO_SEND); WOLFSSL_ENTER("SendClientHello"); + if (ssl == NULL || ssl->arrays == NULL) { + return BAD_FUNC_ARG; + } + if (ssl->suites == NULL) { WOLFSSL_MSG("Bad suites pointer in SendClientHello"); return SUITES_ERROR; diff --git a/wolfssl/wolfcrypt/types.h b/wolfssl/wolfcrypt/types.h index 6b6b544fd..4bcf24a9d 100644 --- a/wolfssl/wolfcrypt/types.h +++ b/wolfssl/wolfcrypt/types.h @@ -315,7 +315,8 @@ decouple library dependencies with standard string, memory and so on. #if defined(WOLFSSL_LINUXKM) && defined(fallthrough) #define FALL_THROUGH fallthrough #else - #define FALL_THROUGH ; __attribute__ ((fallthrough)) + /* Use __ notation to avoid conflicts */ + #define FALL_THROUGH ; __attribute__ ((__fallthrough__)) #endif #endif #endif