Skip to contentSkip to conversation

autoip address set/reset loop

PATCH Geoffrey Van Landeghem 3 participants 3 messages Nov 23, 2022

lore
Share & tools
lore
#0 lore raw

Subject: Re: autoip address set/reset loop

Here is the patch:

From b7750b925714572cba12275e6da49b8b70cd3fbb Mon Sep 17 00:00:00 2001
From: Geoffrey Van Landeghem <[email protected]>
Date: Tue, 22 Nov 2022 19:50:12 +0100
Subject: [PATCH] ipconfig: revert not adding invalid gateway routes

---
 src/ipconfig.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
src/ipconfig.c +5 -1
index 74215e1d..875819a0 100644
@@ -1183,13 +1183,17 @@ int __connman_ipconfig_gateway_add(struct connman_ipconfig *ipconfig)
 
 	DBG("");
 
-	if (!ipconfig->address || !ipconfig->address->gateway)
+	if (!ipconfig->address)
 		return -EINVAL;
 
 	service = __connman_service_lookup_from_index(ipconfig->index);
 	if (!service)
 		return -EINVAL;
 
+	/*
+	 * Gateway is allowed to be NULL here, see
+	 * __connman_connection_gateway_add()
+	 */
 	DBG("type %d gw %s peer %s", ipconfig->type,
 		ipconfig->address->gateway, ipconfig->address->peer);
 
#1 lore raw
Quoted 25 lines · Geoffrey Van Landeghem

Subject: Re: autoip address set/reset loop

Here is the patch:

From b7750b925714572cba12275e6da49b8b70cd3fbb Mon Sep 17 00:00:00 2001
From: Geoffrey Van Landeghem <[email protected]>
Date: Tue, 22 Nov 2022 19:50:12 +0100
Subject: [PATCH] ipconfig: revert not adding invalid gateway routes

---
 src/ipconfig.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
src/ipconfig.c +1 -1
index 74215e1d..875819a0 100644
@@ -1183,13 +1183,17 @@ int __connman_ipconfig_gateway_add(struct connman_ipconfig *ipconfig)
 
 	DBG("");
 
-	if (!ipconfig->address || !ipconfig->address->gateway)
+	if (!ipconfig->address)
 		return -EINVAL;
 

src/ipconfig.c int __connman_ipconfig_gateway_add(struct connman_ipconfig *ipconfig) · line 1198

Quoted 10 lines
src/ipconfig.c +4 -0
 	service = __connman_service_lookup_from_index(ipconfig->index);
 	if (!service)
 		return -EINVAL;
 
+	/*
+	 * Gateway is allowed to be NULL here, see
+	 * __connman_connection_gateway_add()
+	 */
 	DBG("type %d gw %s peer %s", ipconfig->type,
 		ipconfig->address->gateway, ipconfig->address->peer);

If gateway can be null you need to make sure the argument to DBG() is non-null. While glibc handles null for %s other C libraries may crash.

#2 lore raw
In reply to Geoffrey Van Landeghem

Hi Geoffrey

Quoted 8 lines · Geoffrey Van Landeghem

Subject: Re: autoip address set/reset loop

Here is the patch:

From b7750b925714572cba12275e6da49b8b70cd3fbb Mon Sep 17 00:00:00 2001
From: Geoffrey Van Landeghem <[email protected]>
Date: Tue, 22 Nov 2022 19:50:12 +0100
Subject: [PATCH] ipconfig: revert not adding invalid gateway routes

Thanks for digging into this bug. But this trading one bug against another one. If not I need an explanation why this is okay to do.

Thanks,
Daniel