From f5f55aab07ca6a2dfc1080a68c1b28960cdd1b2d Mon Sep 17 00:00:00 2001 From: Junyeon LEE Date: Fri, 7 Apr 2017 12:48:07 +0900 Subject: [PATCH] netutils/webserver: fix potential memory leak When webserver receives a websocket packet, it generates websocket handler for processing the packet and inherits its own context. In this process, mbedtls network file descriptor (fd) context was not inherited properly and changed it. Because of this problem, the websocket client handler thread cannot be released sometimes. Change-Id: I9e70bd506a61091f442e8da8e18c62400b1bb211 Signed-off-by: Junyeon LEE --- apps/netutils/webserver/http_client.c | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/netutils/webserver/http_client.c b/apps/netutils/webserver/http_client.c index 76c3503..b8a25ed 100644 --- a/apps/netutils/webserver/http_client.c +++ b/apps/netutils/webserver/http_client.c @@ -458,6 +458,7 @@ int http_recv_and_handle_request(struct http_client_t *client, struct http_keyva ws->tls_ssl = (mbedtls_ssl_context *)malloc(sizeof(mbedtls_ssl_context)); memcpy(ws->tls_ssl, &client->tls_ssl, sizeof(mbedtls_ssl_context)); ws->tls_conf = &client->server->tls_conf; + mbedtls_ssl_set_bio(ws->tls_ssl, &ws->tls_net, mbedtls_net_send, mbedtls_net_recv, NULL); } #endif pthread_attr_init(&ws->thread_attr); -- 2.7.4