[PATCH] network: Prevent NULL pointer SIGSEGV in set_autoconnect()

Jussi Laakkonen <[email protected]>
Newsgroups dev.linux.lists.connman
Message-ID <[email protected]>
connman_network_set_autoconnect() can be called with NULL network in
some cases when enabling autoconnect. Prevent crash with SIGSEGV by
checking also the network.

Verified and tested by Dragos Cosma ([email protected]) with
ConnMan 1.45. Appeared first in Sailfish OS on upgrade to ConnMan 1.40.
---
 src/network.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/network.c b/src/network.c
index 416a7e74..9b010971 100644
--- a/src/network.c
+++ b/src/network.c
@@ -2121,7 +2121,7 @@ uint16_t connman_network_get_frequency(struct connman_network *network)
 int connman_network_set_autoconnect(struct connman_network *network,
 				bool autoconnect)
 {
-	if (!network->driver || !network->driver->set_autoconnect)
+	if (!network || !network->driver || !network->driver->set_autoconnect)
 		return 0;
 	return network->driver->set_autoconnect(network, autoconnect);
 }
-- 
2.47.3
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.