fixing a memory leak

This commit is contained in:
Tobias Brunner
2008-11-11 09:56:47 +00:00
parent ea625fabf9
commit e7c27b4f3f
2 changed files with 14 additions and 6 deletions
@@ -1756,6 +1756,7 @@ static bool add_bypass_policies()
{
int fd, family, port;
enumerator_t *sockets;
bool status = TRUE;
/* we open an AF_KEY socket to autoload the af_key module. Otherwise
* setsockopt(IPSEC_POLICY) won't work. */
@@ -1797,17 +1798,20 @@ static bool add_bypass_policies()
{
DBG1(DBG_KNL, "unable to set IPSEC_POLICY on socket: %s",
strerror(errno));
return FALSE;
status = FALSE;
break;
}
policy.sadb_x_policy_dir = IPSEC_DIR_INBOUND;
if (setsockopt(fd, sol, ipsec_policy, &policy, sizeof(policy)) < 0)
{
DBG1(DBG_KNL, "unable to set IPSEC_POLICY on socket: %s",
strerror(errno));
return FALSE;
status = FALSE;
break;
}
}
return TRUE;
sockets->destroy(sockets);
return status;
}
/*
@@ -1879,6 +1879,7 @@ static bool add_bypass_policies(private_kernel_pfkey_ipsec_t *this)
{
int fd, family, port;
enumerator_t *sockets;
bool status = TRUE;
sockets = charon->socket->create_enumerator(charon->socket);
while (sockets->enumerate(sockets, &fd, &family, &port))
@@ -1910,17 +1911,20 @@ static bool add_bypass_policies(private_kernel_pfkey_ipsec_t *this)
{
DBG1(DBG_KNL, "unable to set IPSEC_POLICY on socket: %s",
strerror(errno));
return FALSE;
status = FALSE;
break;
}
policy.sadb_x_policy_dir = IPSEC_DIR_INBOUND;
if (setsockopt(fd, sol, ipsec_policy, &policy, sizeof(policy)) < 0)
{
DBG1(DBG_KNL, "unable to set IPSEC_POLICY on socket: %s",
strerror(errno));
return FALSE;
status = FALSE;
break;
}
}
return TRUE;
sockets->destroy(sockets);
return status;
}
/*