diff options
author | Seung-Woo Kim <sw0312.kim@samsung.com> | 2024-09-02 21:41:07 +0900 |
---|---|---|
committer | Seung-Woo Kim <sw0312.kim@samsung.com> | 2024-09-02 21:41:07 +0900 |
commit | de98d8ed48cad1733d14177d6a1579049c8a402f (patch) | |
tree | d605e2c5bbf7f9af392618ae196b4015b2adadd7 | |
parent | c9d3ac9e0012865284537bd550fffca6680487f9 (diff) | |
download | connman-de98d8ed48cad1733d14177d6a1579049c8a402f.tar.gz connman-de98d8ed48cad1733d14177d6a1579049c8a402f.tar.bz2 connman-de98d8ed48cad1733d14177d6a1579049c8a402f.zip |
dhcp: clear c_gateway and c_prefixlen before removeaccepted/tizen/unified/x/20240905.023715accepted/tizen/unified/20240904.172719
Before calling __connman_ipconfig_address_remove(), for specific
ipconfig->method cases, clear c_gateway and c_prefixlen to
prevent use-after-free.
Fixes: d593e995c7c7 ("dhcp: Remove old IP and gateway address")
Change-Id: Ifd171e9f9ce2a77a88953ca9ca8b6dbfec46744b
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
-rw-r--r-- | src/dhcp.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -547,9 +547,17 @@ static void lease_available_cb(GDHCPClient *dhcp_client, gpointer user_data) DBG("c_address %s", c_address); + old_method = __connman_ipconfig_get_method(dhcp->ipconfig); + if (g_strcmp0(address, c_address)) { ip_change = true; if (c_address) { + if (old_method == CONNMAN_IPCONFIG_METHOD_AUTO || + old_method == CONNMAN_IPCONFIG_METHOD_DHCP) { + c_gateway = NULL; + c_prefixlen = 0; + } + /* Remove old ip address */ __connman_ipconfig_address_remove(dhcp->ipconfig); } @@ -563,7 +571,6 @@ static void lease_available_cb(GDHCPClient *dhcp_client, gpointer user_data) } else if (prefixlen != c_prefixlen) ip_change = true; - old_method = __connman_ipconfig_get_method(dhcp->ipconfig); __connman_ipconfig_set_method(dhcp->ipconfig, CONNMAN_IPCONFIG_METHOD_DHCP); |