From: Jukka Rissanen Date: Tue, 15 Nov 2011 11:06:14 +0000 (+0200) Subject: vpn: Add null checks X-Git-Tag: 0.78~47 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c75a3bd3b009b8894fa14d130709642d1bc0c8c6;p=platform%2Fupstream%2Fconnman.git vpn: Add null checks --- diff --git a/plugins/vpn.c b/plugins/vpn.c index 7d55d81..226fabe 100644 --- a/plugins/vpn.c +++ b/plugins/vpn.c @@ -78,6 +78,9 @@ static int stop_vpn(struct connman_provider *provider) return -EINVAL; name = connman_provider_get_driver_name(provider); + if (name == NULL) + return -EINVAL; + vpn_driver_data = g_hash_table_lookup(driver_hash, name); if (vpn_driver_data != NULL && vpn_driver_data->vpn_driver != NULL && @@ -137,10 +140,12 @@ void vpn_died(struct connman_task *task, int exit_code, void *user_data) vpn_exit: if (state != VPN_STATE_READY && state != VPN_STATE_DISCONNECT) { const char *name; - struct vpn_driver_data *vpn_data; + struct vpn_driver_data *vpn_data = NULL; name = connman_provider_get_driver_name(provider); - vpn_data = g_hash_table_lookup(driver_hash, name); + if (name != NULL) + vpn_data = g_hash_table_lookup(driver_hash, name); + if (vpn_data != NULL && vpn_data->vpn_driver->error_code != NULL) ret = vpn_data->vpn_driver->error_code(exit_code); @@ -209,6 +214,9 @@ static void vpn_notify(struct connman_task *task, data = connman_provider_get_data(provider); name = connman_provider_get_driver_name(provider); + if (name == NULL) + return; + vpn_driver_data = g_hash_table_lookup(driver_hash, name); if (vpn_driver_data == NULL) return; @@ -331,6 +339,9 @@ static int vpn_connect(struct connman_provider *provider) connman_provider_set_data(provider, data); name = connman_provider_get_driver_name(provider); + if (name == NULL) + return -EINVAL; + vpn_driver_data = g_hash_table_lookup(driver_hash, name); if (vpn_driver_data != NULL && vpn_driver_data->vpn_driver != NULL && @@ -401,6 +412,9 @@ static int vpn_disconnect(struct connman_provider *provider) return 0; name = connman_provider_get_driver_name(provider); + if (name == NULL) + return 0; + vpn_driver_data = g_hash_table_lookup(driver_hash, name); if (vpn_driver_data->vpn_driver->disconnect) vpn_driver_data->vpn_driver->disconnect();