summaryrefslogtreecommitdiff
path: root/src/connection.c
diff options
context:
space:
mode:
authorJukka Rissanen <jukka.rissanen@linux.intel.com>2012-03-14 17:28:54 +0200
committerPatrik Flykt <patrik.flykt@linux.intel.com>2012-03-19 13:08:53 +0200
commit1a406c25cfc5a08905dbadc7913d4b3998fede7c (patch)
tree464263ee4fe45ac2b21d2778746b176e1af07c4a /src/connection.c
parenta7d631e9612e87212ff97860b44089ccee46aed7 (diff)
downloadconnman-1a406c25cfc5a08905dbadc7913d4b3998fede7c.tar.gz
connman-1a406c25cfc5a08905dbadc7913d4b3998fede7c.tar.bz2
connman-1a406c25cfc5a08905dbadc7913d4b3998fede7c.zip
connection: Avoid stale memory access
Get the active gateway pointer only after the gateway hash has been manipulated by add_gateway(). It is possible that we are accessing stale pointer otherwise.
Diffstat (limited to 'src/connection.c')
-rw-r--r--src/connection.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/connection.c b/src/connection.c
index 545b59f4..e4e21d6b 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -567,11 +567,12 @@ int __connman_connection_gateway_add(struct connman_service *service,
DBG("service %p index %d gateway %s vpn ip %s type %d",
service, index, gateway, peer, type);
- active_gateway = find_active_gateway();
new_gateway = add_gateway(service, index, gateway, type);
if (new_gateway == NULL)
return -EINVAL;
+ active_gateway = find_active_gateway();
+
DBG("active %p index %d new %p", active_gateway,
active_gateway ? active_gateway->index : -1, new_gateway);