netutils/webserver: fix potential memory leak
authorJunyeon LEE <junyeon2.lee@samsung.com>
Fri, 7 Apr 2017 03:48:07 +0000 (12:48 +0900)
committerHeesub Shin <heesub.shin@samsung.com>
Tue, 18 Apr 2017 03:02:08 +0000 (12:02 +0900)
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 <junyeon2.lee@samsung.com>
apps/netutils/webserver/http_client.c

index 76c3503..b8a25ed 100644 (file)
@@ -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);