From a1b6647143657d24b4331b77b82f0a9d83682e48 Mon Sep 17 00:00:00 2001 From: Junyeon LEE Date: Fri, 2 Jun 2017 16:03:25 +0900 Subject: [PATCH] examples/tls: fixes uninitialized timer context error This commit fixes two critical bugs in tls applications. . Uninitialized timer context error can occur when user tried to connect dtls in tls-application. . Unallocates mbedtls_timing_delay_context was used and it can make data abort in ssl_set_timer() Change-Id: I65f061309b9b1e0e346c0bbb003f871e96f46499 Signed-off-by: Junyeon LEE --- apps/examples/tls_client/tls_client_main.c | 7 ++++--- apps/examples/tls_server/tls_server_main.c | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/examples/tls_client/tls_client_main.c b/apps/examples/tls_client/tls_client_main.c index cd27620..58f7920 100644 --- a/apps/examples/tls_client/tls_client_main.c +++ b/apps/examples/tls_client/tls_client_main.c @@ -358,7 +358,9 @@ struct options { int fallback; /* is this a fallback connection? */ int extended_ms; /* negotiate extended master secret? */ int etm; /* negotiate encrypt then mac? */ -} opt; +}; + +static struct options opt; static void my_debug(void *ctx, int level, const char *file, int line, const char *str) { @@ -469,7 +471,7 @@ int tls_client_cb(void *args) mbedtls_ssl_config conf; mbedtls_ssl_session saved_session; #if defined(MBEDTLS_TIMING_C) - mbedtls_timing_delay_context *timer; + mbedtls_timing_delay_context timer; #endif #if defined(MBEDTLS_X509_CRT_PARSE_C) uint32_t flags; @@ -1605,7 +1607,6 @@ exit: mbedtls_printf("Last error was: -0x%X - %s\n\n", -ret, error_buf); } #endif - mbedtls_net_free(&server_fd); #if defined(MBEDTLS_X509_CRT_PARSE_C) diff --git a/apps/examples/tls_server/tls_server_main.c b/apps/examples/tls_server/tls_server_main.c index 27613ec..72ab315 100644 --- a/apps/examples/tls_server/tls_server_main.c +++ b/apps/examples/tls_server/tls_server_main.c @@ -416,7 +416,9 @@ struct options { uint32_t hs_to_max; /* Max value of DTLS handshake timer */ int badmac_limit; /* Limit of records with bad MAC */ int retry; /* Server retry count */ -} opt; +}; + +static struct options opt; static void my_debug(void *ctx, int level, const char *file, int line, const char *str) { -- 2.7.4