From 801ac2d6569d061e76a5e869759866b4bb322bea Mon Sep 17 00:00:00 2001 From: Daniele Lacamera Date: Wed, 17 Mar 2021 08:49:51 +0100 Subject: [PATCH] Fixed scope of stack variables (found via asan) --- src/internal.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/internal.c b/src/internal.c index b726b08..f919b92 100644 --- a/src/internal.c +++ b/src/internal.c @@ -715,6 +715,9 @@ int wolfSSH_ProcessBuffer(WOLFSSH_CTX* ctx, byte* der; word32 derSz, scratch = 0; union wolfSSH_key *key_ptr = NULL; +#ifndef WOLFSSH_SMALL_STACK + union wolfSSH_key key; +#endif (void)dynamicType; (void)heap; @@ -770,7 +773,6 @@ int wolfSSH_ProcessBuffer(WOLFSSH_CTX* ctx, return WS_MEMORY_E; } #else - union wolfSSH_key key; key_ptr = &key; #endif /* WOLFSSH_SMALL_STACK */ @@ -2831,6 +2833,7 @@ static int DoKexDhReply(WOLFSSH* ssh, byte* buf, word32 len, word32* idx) ecc_key *key_ptr; #ifndef WOLFSSH_SMALL_STACK struct wolfSSH_sigKeyBlock s_sigKeyBlock; + ecc_key key_s; #endif WLOG(WS_LOG_DEBUG, "Entering DoKexDhReply()"); @@ -3035,7 +3038,6 @@ static int DoKexDhReply(WOLFSSH* ssh, byte* buf, word32 len, word32* idx) #else /* ! WOLFSSH_SMALL_STACK */ #ifndef WOLFSSH_NO_ECDSA - ecc_key key_s; key_ptr = &key_s; #endif sigKeyBlock_ptr = &s_sigKeyBlock;