From 1b77cda621e636c4b5cca13ae71771d65351a949 Mon Sep 17 00:00:00 2001 From: Mingjie Shen Date: Wed, 19 Apr 2023 17:07:42 -0400 Subject: [PATCH] Change storage-class of secret_buf to static Storing the address of a local variable (`secret_buf`) in non-local memory (`prf_ptr->secret`) can cause a dangling pointer bug if the address is used after the function returns. --- .../nanostack/sal-stack-nanostack/source/Security/TLS/tls_lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connectivity/nanostack/sal-stack-nanostack/source/Security/TLS/tls_lib.c b/connectivity/nanostack/sal-stack-nanostack/source/Security/TLS/tls_lib.c index aa70856c18..f276c30e5a 100644 --- a/connectivity/nanostack/sal-stack-nanostack/source/Security/TLS/tls_lib.c +++ b/connectivity/nanostack/sal-stack-nanostack/source/Security/TLS/tls_lib.c @@ -2095,7 +2095,7 @@ void tls_master_key_cal(tls_heap_t *heap_ptr, sec_suite_t *tls_suite) { uint8_t *ptr; prf_sec_param_t *prf_ptr = shalib_prf_param_get(); - uint8_t secret_buf[2 + 16 + 2 + 16]; + static uint8_t secret_buf[2 + 16 + 2 + 16]; tr_debug("CAL Master secret:"); //Her have to to be set check is #ifdef ECC