[PATCH 2/2] dhcp: Ignore empty DHCP Option 252

Ed Rose | Tewke <[email protected]> Thu, 12 Mar 2026 15:15:02 +0000
Newsgroups dev.linux.lists.connman
Message-ID <[email protected]>
Some routers, notably Asus, intentionally send a DHCP option 252=0A=
(proxy autoconfiguration) with a payload of '\n'. This seems to be to=0A=
workaround an overly chatty windows service and improve performance.=0A=
=0A=
Connman would check the length of the string and then strip it before=0A=
using the value. This changes the order so the string is stripped first,=0A=
then the length is checked to allow us to ignore values that contain=0A=
only whitespace.=0A=
---=0A=
 src/dhcp.c | 7 +++++--=0A=
 1 file changed, 5 insertions(+), 2 deletions(-)=0A=
=0A=
diff --git a/src/dhcp.c b/src/dhcp.c=0A=
index c84f1de4..163a347f 100644=0A=
--- a/src/dhcp.c=0A=
+++ b/src/dhcp.c=0A=
@@ -352,7 +352,7 @@ static bool apply_lease_available_on_network(GDHCPClien=
t *dhcp_client,=0A=
=0A=
 	option =3D g_dhcp_client_get_option(dhcp_client, 252);=0A=
 	if (option)=0A=
-		pac =3D g_strdup(option->data);=0A=
+		pac =3D g_strstrip(g_strdup(option->data));=0A=
=0A=
 	option =3D g_dhcp_client_get_option(dhcp_client, G_DHCP_DNS_SERVER);=0A=
 	ns_entries =3D g_list_length(option);=0A=
@@ -418,11 +418,14 @@ static bool apply_lease_available_on_network(GDHCPCli=
ent *dhcp_client,=0A=
 		g_strfreev(timeservers);=0A=
 	}=0A=
=0A=
-	if (g_strcmp0(pac, dhcp->pac) !=3D 0) {=0A=
+	if (pac && strlen(pac) && g_strcmp0(pac, dhcp->pac) !=3D 0) {=0A=
 		g_free(dhcp->pac);=0A=
 		dhcp->pac =3D pac;=0A=
=0A=
 		__connman_service_set_proxy_autoconfig(service, dhcp->pac);=0A=
+	} else if (pac) {=0A=
+		g_free(pac);=0A=
+		pac =3D NULL;=0A=
 	}=0A=
=0A=
 	if (connman_setting_get_bool("Enable6to4"))=0A=
--=0A=
2.43.0=0A=
=0A=