From 41e04a0df5feaeb7906ebabd596e99db90378794 Mon Sep 17 00:00:00 2001 From: Yu Jiung Date: Fri, 29 Jul 2016 17:23:22 +0900 Subject: [PATCH] Fix SVace issue WGID 140308 Change-Id: I77ca420a6927312f205a08938c86208151f5fbe6 Signed-off-by: Yu jiung --- packaging/net-config.spec | 2 +- src/network-state.c | 31 +++++++++++++++++++------------ 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/packaging/net-config.spec b/packaging/net-config.spec index ec5f7a8..0bcaa23 100755 --- a/packaging/net-config.spec +++ b/packaging/net-config.spec @@ -1,6 +1,6 @@ Name: net-config Summary: TIZEN Network Configuration service -Version: 1.1.82 +Version: 1.1.83 Release: 2 Group: System/Network License: Apache-2.0 diff --git a/src/network-state.c b/src/network-state.c index 41d9811..3f083f6 100755 --- a/src/network-state.c +++ b/src/network-state.c @@ -182,6 +182,11 @@ static void __netconfig_get_default_connection_info(const char *profile) } g_variant_get(message, "(a(oa{sv}))", &service); + if (service == NULL) { + ERR("Failed to get services iter"); + goto done; + } + while (g_variant_iter_loop(service, "(oa{sv})", &obj_path, &iter)) { if (g_strcmp0(obj_path, profile) == 0) { g_free(obj_path); @@ -190,7 +195,7 @@ static void __netconfig_get_default_connection_info(const char *profile) } } - if (found_profile == 0) { + if (iter == NULL || found_profile == 0) { ERR("Profile %s doesn't exist", profile); goto done; } @@ -207,36 +212,42 @@ static void __netconfig_get_default_connection_info(const char *profile) } } else if (g_strcmp0(key, "Ethernet") == 0) { g_variant_get(next, "a{sv}", &iter1); + if (iter1 == NULL) + continue; while (g_variant_iter_loop(iter1, "{sv}", &key1, &variant)) { if (g_strcmp0(key1, "Interface") == 0) { value = g_variant_get_string(variant, NULL); netconfig_default_connection_info.ifname = g_strdup(value); } } - if (iter1) - g_variant_iter_free(iter1); + g_variant_iter_free(iter1); } else if (g_strcmp0(key, "IPv4") == 0) { g_variant_get(next, "a{sv}", &iter1); + if (iter1 == NULL) + continue; while (g_variant_iter_loop(iter1, "{sv}", &key1, &variant)) { if (g_strcmp0(key1, "Address") == 0) { value = g_variant_get_string(variant, NULL); netconfig_default_connection_info.ipaddress = g_strdup(value); } } - if (iter1) - g_variant_iter_free(iter1); + g_variant_iter_free(iter1); } else if (g_strcmp0(key, "IPv6") == 0) { g_variant_get(next, "a{sv}", &iter1); + if (iter1 == NULL) + continue; while (g_variant_iter_loop(iter1, "{sv}", &key1, &variant)) { if (g_strcmp0(key1, "Address") == 0) { value = g_variant_get_string(variant, NULL); netconfig_default_connection_info.ipaddress6 = g_strdup(value); } } - if (iter1) - g_variant_iter_free(iter1); + g_variant_iter_free(iter1); + } else if (g_strcmp0(key, "Proxy") == 0) { g_variant_get(next, "a{sv}", &iter1); + if (iter1 == NULL) + continue; while (g_variant_iter_loop(iter1, "{sv}", &key2, &variant2)) { GVariantIter *iter_sub = NULL; @@ -270,8 +281,7 @@ static void __netconfig_get_default_connection_info(const char *profile) } } } - if (iter1) - g_variant_iter_free(iter1); + g_variant_iter_free(iter1); } else if (g_strcmp0(key, "Frequency") == 0) { if (g_variant_is_of_type(next, G_VARIANT_TYPE_UINT16)) { freq = g_variant_get_uint16(next); @@ -287,9 +297,6 @@ done: if (iter) g_variant_iter_free(iter); - if (iter1) - g_variant_iter_free(iter1); - if (service) g_variant_iter_free(service); -- 2.7.4