From: Patrik Flykt <patrik.fl...@linux.intel.com> When setting IP address information via D-Bus, first create a new ipconfig structure to hold the values. If the values were validated correctly, update the service ipconfig structure with the new values. Done this way, the current IP configuration is unaffected if erroneous values are received via D-Bus.
Fixes BMC#25930 --- src/service.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/service.c b/src/service.c index 106da04..afa3050 100644 --- a/src/service.c +++ b/src/service.c @@ -2967,22 +2967,45 @@ static int set_ipconfig(struct connman_service *service, enum connman_service_state *new_state) { enum connman_ipconfig_method old_method; + struct connman_ipconfig *new_ipconfig; enum connman_ipconfig_method method = CONNMAN_IPCONFIG_METHOD_UNKNOWN; enum connman_ipconfig_type type; - int err; + int err, index; if (ipconfig == NULL) return -EINVAL; old_method = __connman_ipconfig_get_method(ipconfig); + type = __connman_ipconfig_get_config_type(ipconfig); + index = __connman_ipconfig_get_index(ipconfig); + + if (type == CONNMAN_IPCONFIG_TYPE_IPV4) + new_ipconfig = create_ip4config(service, index, + CONNMAN_IPCONFIG_METHOD_UNKNOWN); + else if (type == CONNMAN_IPCONFIG_TYPE_IPV6) + new_ipconfig = create_ip6config(service, index); + else + return -ENXIO; + + err = __connman_ipconfig_set_config(new_ipconfig, array); + if (err < 0) { + __connman_ipconfig_unref(new_ipconfig); + return err; + } if (is_connecting_state(service, state) || is_connected_state(service, state)) __connman_network_clear_ipconfig(service->network, ipconfig); - err = __connman_ipconfig_set_config(ipconfig, array); + ipconfig = new_ipconfig; + if (type == CONNMAN_IPCONFIG_TYPE_IPV4) + service->ipconfig_ipv4 = ipconfig; + else if (type == CONNMAN_IPCONFIG_TYPE_IPV6) + service->ipconfig_ipv6 = ipconfig; + + __connman_ipconfig_enable(ipconfig); + method = __connman_ipconfig_get_method(ipconfig); - type = __connman_ipconfig_get_config_type(ipconfig); if (type == CONNMAN_IPCONFIG_TYPE_IPV4) { if (err == 0 && old_method == CONNMAN_IPCONFIG_METHOD_OFF && -- 1.7.10.4 _______________________________________________ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman