diff options
author | Jukka Rissanen <jukka.rissanen@linux.intel.com> | 2012-11-30 11:30:41 +0200 |
---|---|---|
committer | Patrik Flykt <patrik.flykt@linux.intel.com> | 2012-11-30 15:01:18 +0200 |
commit | f0191c24ad067e927c4bfe40f3933011724bda64 (patch) | |
tree | 6aa75cc08e4a27ab28dc260daf19f0a0ef512e74 /vpn | |
parent | f701b508e41288867845f5c4f2589903671e8c31 (diff) | |
download | connman-f0191c24ad067e927c4bfe40f3933011724bda64.tar.gz connman-f0191c24ad067e927c4bfe40f3933011724bda64.tar.bz2 connman-f0191c24ad067e927c4bfe40f3933011724bda64.zip |
openconnect: Domain pointer was used incorrectly
We must allocate the domain name from the heap and not
point to it directly because the dbus library will deallocate
it and we will have invalid memory access.
Diffstat (limited to 'vpn')
-rw-r--r-- | vpn/plugins/openconnect.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/vpn/plugins/openconnect.c b/vpn/plugins/openconnect.c index af300632..d36662cd 100644 --- a/vpn/plugins/openconnect.c +++ b/vpn/plugins/openconnect.c @@ -57,7 +57,7 @@ static int oc_notify(DBusMessage *msg, struct vpn_provider *provider) { DBusMessageIter iter, dict; const char *reason, *key, *value; - const char *domain = NULL; + char *domain = NULL; char *addressv4 = NULL, *addressv6 = NULL; char *netmask = NULL, *gateway = NULL; unsigned char prefix_len = 0; @@ -76,7 +76,7 @@ static int oc_notify(DBusMessage *msg, struct vpn_provider *provider) if (strcmp(reason, "connect")) return VPN_STATE_DISCONNECT; - domain = vpn_provider_get_string(provider, "VPN.Domain"); + domain = g_strdup(vpn_provider_get_string(provider, "VPN.Domain")); dbus_message_iter_recurse(&iter, &dict); @@ -126,8 +126,10 @@ static int oc_notify(DBusMessage *msg, struct vpn_provider *provider) if (!strcmp(key, "CISCO_PROXY_PAC")) vpn_provider_set_pac(provider, value); - if (domain == NULL && !strcmp(key, "CISCO_DEF_DOMAIN")) - domain = value; + if (domain == NULL && !strcmp(key, "CISCO_DEF_DOMAIN")) { + g_free(domain); + domain = g_strdup(value); + } if (g_str_has_prefix(key, "CISCO_SPLIT_INC") == TRUE || g_str_has_prefix(key, "CISCO_IPV6_SPLIT_INC") == TRUE) @@ -150,6 +152,7 @@ static int oc_notify(DBusMessage *msg, struct vpn_provider *provider) g_free(addressv6); g_free(netmask); g_free(gateway); + g_free(domain); return VPN_STATE_FAILURE; } @@ -167,6 +170,7 @@ static int oc_notify(DBusMessage *msg, struct vpn_provider *provider) g_free(addressv6); g_free(netmask); g_free(gateway); + g_free(domain); connman_ipaddress_free(ipaddress); return VPN_STATE_CONNECT; |