examples/tls: fixes uninitialized timer context error
authorJunyeon LEE <junyeon2.lee@samsung.com>
Fri, 2 Jun 2017 07:03:25 +0000 (16:03 +0900)
committerEunBong Song <eunb.song@samsung.com>
Tue, 11 Jul 2017 11:10:03 +0000 (20:10 +0900)
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 <junyeon2.lee@samsung.com>
apps/examples/tls_client/tls_client_main.c
apps/examples/tls_server/tls_server_main.c

index cd27620..58f7920 100644 (file)
@@ -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)
index 27613ec..72ab315 100644 (file)
@@ -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)
 {