diff options
author | Samuel Ortiz <sameo@linux.intel.com> | 2009-07-07 18:02:27 +0200 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2009-07-07 10:26:54 -0700 |
commit | cbcec6c878630ed341079d52e44506f6e9c79e8f (patch) | |
tree | a8b997c71ee3568b726a2c849c9f0a0036f5370c | |
parent | 74a26e212a48d86c6f5aaa70a15173cc1f37c994 (diff) | |
download | connman-cbcec6c878630ed341079d52e44506f6e9c79e8f.tar.gz connman-cbcec6c878630ed341079d52e44506f6e9c79e8f.tar.bz2 connman-cbcec6c878630ed341079d52e44506f6e9c79e8f.zip |
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.
-rw-r--r-- | src/device.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/device.c b/src/device.c index aa53304e..ec28eb09 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); |