diff options
author | Martin Willi <martin@strongswan.org> | 2009-03-03 14:56:17 +0000 |
---|---|---|
committer | Martin Willi <martin@strongswan.org> | 2009-03-03 14:56:17 +0000 |
commit | d9ad73d867e99870a25f4cad47bf50ee0a878821 (patch) | |
tree | a783cb7ba612d472a55521e6e094a9dc01fd677b | |
parent | 7b2a032d28a73500d2b5bfdd296e834229b73705 (diff) | |
download | strongswan-d9ad73d867e99870a25f4cad47bf50ee0a878821.tar.bz2 strongswan-d9ad73d867e99870a25f4cad47bf50ee0a878821.tar.xz |
fixed format string argument error, resulting in crash
fixed memleak if pool not found
-rw-r--r-- | src/charon/config/attributes/attribute_manager.c | 16 | ||||
-rw-r--r-- | src/charon/plugins/sql/sql_attribute.c | 2 |
2 files changed, 15 insertions, 3 deletions
diff --git a/src/charon/config/attributes/attribute_manager.c b/src/charon/config/attributes/attribute_manager.c index b919c4261..a069c954a 100644 --- a/src/charon/config/attributes/attribute_manager.c +++ b/src/charon/config/attributes/attribute_manager.c @@ -17,6 +17,7 @@ #include "attribute_manager.h" +#include <daemon.h> #include <utils/linked_list.h> #include <utils/mutex.h> @@ -53,7 +54,7 @@ static host_t* acquire_address(private_attribute_manager_t *this, enumerator_t *enumerator; attribute_provider_t *current; host_t *host = NULL; - + this->lock->read_lock(this->lock); enumerator = this->providers->create_enumerator(this->providers); while (enumerator->enumerate(enumerator, ¤t)) @@ -67,6 +68,10 @@ static host_t* acquire_address(private_attribute_manager_t *this, enumerator->destroy(enumerator); this->lock->unlock(this->lock); + if (!host) + { + DBG1(DBG_CFG, "acquiring address from pool '%s' failed", pool); + } return host; } @@ -78,18 +83,25 @@ static void release_address(private_attribute_manager_t *this, { enumerator_t *enumerator; attribute_provider_t *current; - + bool found = FALSE; + this->lock->read_lock(this->lock); enumerator = this->providers->create_enumerator(this->providers); while (enumerator->enumerate(enumerator, ¤t)) { if (current->release_address(current, pool, address, id)) { + found = TRUE; break; } } enumerator->destroy(enumerator); this->lock->unlock(this->lock); + + if (!found) + { + DBG1(DBG_CFG, "releasing address to pool '%s' failed", pool); + } } /** diff --git a/src/charon/plugins/sql/sql_attribute.c b/src/charon/plugins/sql/sql_attribute.c index cd6f7c0cd..826aa8318 100644 --- a/src/charon/plugins/sql/sql_attribute.c +++ b/src/charon/plugins/sql/sql_attribute.c @@ -89,7 +89,7 @@ static u_int get_pool(private_sql_attribute_t *this, char *name, u_int *timeout) e->destroy(e); return pool; } - DBG1(DBG_CFG, "ip pool '%s' not found"); + DESTROY_IF(e); return 0; } |