From cbcec6c878630ed341079d52e44506f6e9c79e8f Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Tue, 7 Jul 2009 18:02:27 +0200 Subject: [PATCH] Add checks for networks if attribute is not available We do actually want to check for NULL pointers, not to prevent g_strcmp0 from crashing, but because we want to compare the 2 pointers when we've been given one and the network we're looking at has a pointer too. For example if we call find_network() without an address, it basically means "find a network with an SSID, and with _any_ address". But then we're going to compare a NULL pointer with the network's address and that's gonna be -1. As a consequence, we'll skip this network while we shouldnt. --- src/device.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/device.c b/src/device.c index aa53304..ec28eb0 100644 --- a/src/device.c +++ b/src/device.c @@ -512,13 +512,15 @@ static struct connman_network *find_network(struct connman_device *device, if (tmp_ssid && memcmp(ssid, tmp_ssid, tmp_ssid_size)) continue; - if (g_strcmp0(security, tmp_security) != 0) + if (security && tmp_security && + g_strcmp0(security, tmp_security) != 0) continue; - if (g_strcmp0(mode, tmp_mode) != 0) + if (mode && tmp_mode && g_strcmp0(mode, tmp_mode) != 0) continue; - if (g_strcmp0(address, tmp_address) != 0) + if (address && tmp_address && + g_strcmp0(address, tmp_address) != 0) continue; return connman_network_ref(value); -- 2.7.4