summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeung-Woo Kim <sw0312.kim@samsung.com>2024-09-02 21:41:07 +0900
committerSeung-Woo Kim <sw0312.kim@samsung.com>2024-09-02 21:41:07 +0900
commitde98d8ed48cad1733d14177d6a1579049c8a402f (patch)
treed605e2c5bbf7f9af392618ae196b4015b2adadd7
parentc9d3ac9e0012865284537bd550fffca6680487f9 (diff)
downloadconnman-de98d8ed48cad1733d14177d6a1579049c8a402f.tar.gz
connman-de98d8ed48cad1733d14177d6a1579049c8a402f.tar.bz2
connman-de98d8ed48cad1733d14177d6a1579049c8a402f.zip
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.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/dhcp.c b/src/dhcp.c
index 5ad1efba..e04e58a4 100644
--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -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);