ofono: Fix potential crash
authorGuillaume Zajac <guillaume.zajac@linux.intel.com>
Wed, 27 Jun 2012 15:00:29 +0000 (17:00 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Sat, 30 Jun 2012 08:33:04 +0000 (10:33 +0200)
If a dummy context is created, it might happen
that its index is equal to -1. In this particular case
the IP address has not been copied to context->address
during ipv4 extraction.
If we force from oFono a context activation, it will
make ConnMan crashing on set_connected().

plugins/ofono.c

index ae419be..d284c2b 100644 (file)
@@ -260,6 +260,12 @@ static void set_connected(struct modem_data *modem)
 
        DBG("%s", modem->path);
 
+       if (modem->context->index < 0 ||
+                       modem->context->ipv4_address == NULL) {
+               connman_error("Invalid index and/or address");
+               return;
+       }
+
        connman_network_set_index(modem->network, modem->context->index);
 
        switch (modem->context->ipv4_method) {