From 8f4dbb1aa7ce0b39a12b9cc908a8660c5d61f0cc Mon Sep 17 00:00:00 2001 From: Rahul Jain Date: Tue, 21 Jul 2020 16:48:45 +0530 Subject: [PATCH] Svace issues: Null check and memory leaks Change-Id: I937af7e6dbe3a919c1d0b0d7dee4b481c2ef0982 --- plugins/wifi.c | 2 +- src/config.c | 4 ++++ src/dnsproxy.c | 7 +++++++ src/network.c | 4 ++++ src/session.c | 8 ++++++++ 5 files changed, 24 insertions(+), 1 deletion(-) diff --git a/plugins/wifi.c b/plugins/wifi.c index 7f26417..2f70ee7 100755 --- a/plugins/wifi.c +++ b/plugins/wifi.c @@ -2986,7 +2986,7 @@ static int mesh_scan(struct connman_device *device) wifi = connman_device_get_data(device); - if (!wifi->mesh_interface) + if (!wifi || !wifi->mesh_interface) return -ENOTSUP; mesh_info = wifi->mesh_info; diff --git a/src/config.c b/src/config.c index 0e550e4..56ca2b8 100644 --- a/src/config.c +++ b/src/config.c @@ -647,7 +647,11 @@ static bool load_service(GKeyFile *keyfile, const char *group, unsigned int ssid_len; ssid_len = strlen(service->name); +#if defined TIZEN_EXT + ssid = g_try_malloc0(ssid_len + 1); +#else ssid = g_try_malloc0(ssid_len); +#endif if (!ssid) goto err; diff --git a/src/dnsproxy.c b/src/dnsproxy.c index b244a02..178e98f 100755 --- a/src/dnsproxy.c +++ b/src/dnsproxy.c @@ -2177,8 +2177,15 @@ static int forward_dns_reply(unsigned char *reply, int reply_len, int protocol, req->resplen = 0; req->resp = g_try_malloc(reply_len); +#if defined TIZEN_EXT + if (!req->resp) { + g_free(new_reply); + return -ENOMEM; + } +#else if (!req->resp) return -ENOMEM; +#endif memcpy(req->resp, reply, reply_len); req->resplen = reply_len; diff --git a/src/network.c b/src/network.c index 243b502..636da18 100755 --- a/src/network.c +++ b/src/network.c @@ -735,6 +735,10 @@ static int dhcpv6_set_addresses(struct connman_network *network) network->connecting = false; ipconfig_ipv6 = __connman_service_get_ip6config(service); +#if defined TIZEN_EXT + if (!ipconfig_ipv6) + goto err; +#endif err = __connman_ipconfig_address_add(ipconfig_ipv6); if (err < 0) goto err; diff --git a/src/session.c b/src/session.c index 808931a..6000b6d 100644 --- a/src/session.c +++ b/src/session.c @@ -1756,8 +1756,16 @@ static bool session_match_service(struct connman_session *session, service_type = connman_service_get_type(service); ifname = connman_service_get_interface(service); + +#if defined TIZEN_EXT + if (bearer_type == current_service_type) { + g_free(ifname); + return false; + } +#else if (bearer_type == current_service_type) return false; +#endif if (bearer_type == service_type && (session->info->config.allowed_interface == NULL || -- 2.7.4