From 8beabba8c702d04e7de5ad04d6ecbcf5b91e24ce Mon Sep 17 00:00:00 2001 From: Guillaume Zajac Date: Wed, 27 Jun 2012 17:00:29 +0200 Subject: [PATCH] ofono: Fix potential crash 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 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/ofono.c b/plugins/ofono.c index ae419be..d284c2b 100644 --- a/plugins/ofono.c +++ b/plugins/ofono.c @@ -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) { -- 2.7.4