fixed end->sourceip memory leak in ipsec starter
This commit is contained in:
+26
-34
@@ -107,8 +107,7 @@ static void default_values(starter_config_t *cfg)
|
|||||||
else if (streq(kw->value, sn)) { conn->policy &= ~fl; } \
|
else if (streq(kw->value, sn)) { conn->policy &= ~fl; } \
|
||||||
else { plog("# bad policy value: %s=%s", kw->entry->name, kw->value); cfg->err++; }
|
else { plog("# bad policy value: %s=%s", kw->entry->name, kw->value); cfg->err++; }
|
||||||
|
|
||||||
static void
|
static void load_setup(starter_config_t *cfg, config_parsed_t *cfgp)
|
||||||
load_setup(starter_config_t *cfg, config_parsed_t *cfgp)
|
|
||||||
{
|
{
|
||||||
kw_list_t *kw;
|
kw_list_t *kw;
|
||||||
|
|
||||||
@@ -421,8 +420,8 @@ err:
|
|||||||
/*
|
/*
|
||||||
* handles left|right=<FQDN> DNS resolution failure
|
* handles left|right=<FQDN> DNS resolution failure
|
||||||
*/
|
*/
|
||||||
static void
|
static void handle_dns_failure(const char *label, starter_end_t *end,
|
||||||
handle_dns_failure( const char *label, starter_end_t *end, starter_config_t *cfg)
|
starter_config_t *cfg)
|
||||||
{
|
{
|
||||||
if (end->dns_failed)
|
if (end->dns_failed)
|
||||||
{
|
{
|
||||||
@@ -442,8 +441,8 @@ handle_dns_failure( const char *label, starter_end_t *end, starter_config_t *cfg
|
|||||||
/*
|
/*
|
||||||
* handles left|rightfirewall and left|rightupdown parameters
|
* handles left|rightfirewall and left|rightupdown parameters
|
||||||
*/
|
*/
|
||||||
static void
|
static void handle_firewall(const char *label, starter_end_t *end,
|
||||||
handle_firewall( const char *label, starter_end_t *end, starter_config_t *cfg)
|
starter_config_t *cfg)
|
||||||
{
|
{
|
||||||
if (end->firewall && (end->seen & LELEM(KW_FIREWALL - KW_END_FIRST)))
|
if (end->firewall && (end->seen & LELEM(KW_FIREWALL - KW_END_FIRST)))
|
||||||
{
|
{
|
||||||
@@ -463,8 +462,7 @@ handle_firewall( const char *label, starter_end_t *end, starter_config_t *cfg)
|
|||||||
/*
|
/*
|
||||||
* parse a conn section
|
* parse a conn section
|
||||||
*/
|
*/
|
||||||
static void
|
static void load_conn(starter_conn_t *conn, kw_list_t *kw, starter_config_t *cfg)
|
||||||
load_conn(starter_conn_t *conn, kw_list_t *kw, starter_config_t *cfg)
|
|
||||||
{
|
{
|
||||||
char *conn_name = (conn->name == NULL)? "%default":conn->name;
|
char *conn_name = (conn->name == NULL)? "%default":conn->name;
|
||||||
|
|
||||||
@@ -720,8 +718,7 @@ load_conn(starter_conn_t *conn, kw_list_t *kw, starter_config_t *cfg)
|
|||||||
/*
|
/*
|
||||||
* initialize a conn object with the default conn
|
* initialize a conn object with the default conn
|
||||||
*/
|
*/
|
||||||
static void
|
static void conn_default(char *name, starter_conn_t *conn, starter_conn_t *def)
|
||||||
conn_default(char *name, starter_conn_t *conn, starter_conn_t *def)
|
|
||||||
{
|
{
|
||||||
memcpy(conn, def, sizeof(starter_conn_t));
|
memcpy(conn, def, sizeof(starter_conn_t));
|
||||||
conn->name = clone_str(name);
|
conn->name = clone_str(name);
|
||||||
@@ -734,8 +731,7 @@ conn_default(char *name, starter_conn_t *conn, starter_conn_t *def)
|
|||||||
/*
|
/*
|
||||||
* parse a ca section
|
* parse a ca section
|
||||||
*/
|
*/
|
||||||
static void
|
static void load_ca(starter_ca_t *ca, kw_list_t *kw, starter_config_t *cfg)
|
||||||
load_ca(starter_ca_t *ca, kw_list_t *kw, starter_config_t *cfg)
|
|
||||||
{
|
{
|
||||||
char *ca_name = (ca->name == NULL)? "%default":ca->name;
|
char *ca_name = (ca->name == NULL)? "%default":ca->name;
|
||||||
|
|
||||||
@@ -788,8 +784,7 @@ load_ca(starter_ca_t *ca, kw_list_t *kw, starter_config_t *cfg)
|
|||||||
/*
|
/*
|
||||||
* initialize a ca object with the default ca
|
* initialize a ca object with the default ca
|
||||||
*/
|
*/
|
||||||
static void
|
static void ca_default(char *name, starter_ca_t *ca, starter_ca_t *def)
|
||||||
ca_default(char *name, starter_ca_t *ca, starter_ca_t *def)
|
|
||||||
{
|
{
|
||||||
memcpy(ca, def, sizeof(starter_ca_t));
|
memcpy(ca, def, sizeof(starter_ca_t));
|
||||||
ca->name = clone_str(name);
|
ca->name = clone_str(name);
|
||||||
@@ -797,11 +792,11 @@ ca_default(char *name, starter_ca_t *ca, starter_ca_t *def)
|
|||||||
clone_args(KW_CA_FIRST, KW_CA_LAST, (char *)ca, (char *)def);
|
clone_args(KW_CA_FIRST, KW_CA_LAST, (char *)ca, (char *)def);
|
||||||
}
|
}
|
||||||
|
|
||||||
static kw_list_t*
|
static kw_list_t* find_also_conn(const char* name, starter_conn_t *conn,
|
||||||
find_also_conn(const char* name, starter_conn_t *conn, starter_config_t *cfg);
|
starter_config_t *cfg);
|
||||||
|
|
||||||
static void
|
static void load_also_conns(starter_conn_t *conn, also_t *also,
|
||||||
load_also_conns(starter_conn_t *conn, also_t *also, starter_config_t *cfg)
|
starter_config_t *cfg)
|
||||||
{
|
{
|
||||||
while (also != NULL)
|
while (also != NULL)
|
||||||
{
|
{
|
||||||
@@ -827,8 +822,8 @@ load_also_conns(starter_conn_t *conn, also_t *also, starter_config_t *cfg)
|
|||||||
/*
|
/*
|
||||||
* find a conn included by also
|
* find a conn included by also
|
||||||
*/
|
*/
|
||||||
static kw_list_t*
|
static kw_list_t* find_also_conn(const char* name, starter_conn_t *conn,
|
||||||
find_also_conn(const char* name, starter_conn_t *conn, starter_config_t *cfg)
|
starter_config_t *cfg)
|
||||||
{
|
{
|
||||||
starter_conn_t *c = cfg->conn_first;
|
starter_conn_t *c = cfg->conn_first;
|
||||||
|
|
||||||
@@ -854,11 +849,10 @@ find_also_conn(const char* name, starter_conn_t *conn, starter_config_t *cfg)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static kw_list_t*
|
static kw_list_t* find_also_ca(const char* name, starter_ca_t *ca,
|
||||||
find_also_ca(const char* name, starter_ca_t *ca, starter_config_t *cfg);
|
starter_config_t *cfg);
|
||||||
|
|
||||||
static void
|
static void load_also_cas(starter_ca_t *ca, also_t *also, starter_config_t *cfg)
|
||||||
load_also_cas(starter_ca_t *ca, also_t *also, starter_config_t *cfg)
|
|
||||||
{
|
{
|
||||||
while (also != NULL)
|
while (also != NULL)
|
||||||
{
|
{
|
||||||
@@ -884,8 +878,8 @@ load_also_cas(starter_ca_t *ca, also_t *also, starter_config_t *cfg)
|
|||||||
/*
|
/*
|
||||||
* find a ca included by also
|
* find a ca included by also
|
||||||
*/
|
*/
|
||||||
static kw_list_t*
|
static kw_list_t* find_also_ca(const char* name, starter_ca_t *ca,
|
||||||
find_also_ca(const char* name, starter_ca_t *ca, starter_config_t *cfg)
|
starter_config_t *cfg)
|
||||||
{
|
{
|
||||||
starter_ca_t *c = cfg->ca_first;
|
starter_ca_t *c = cfg->ca_first;
|
||||||
|
|
||||||
@@ -914,8 +908,7 @@ find_also_ca(const char* name, starter_ca_t *ca, starter_config_t *cfg)
|
|||||||
/*
|
/*
|
||||||
* free the memory used by also_t objects
|
* free the memory used by also_t objects
|
||||||
*/
|
*/
|
||||||
static void
|
static void free_also(also_t *head)
|
||||||
free_also(also_t *head)
|
|
||||||
{
|
{
|
||||||
while (head != NULL)
|
while (head != NULL)
|
||||||
{
|
{
|
||||||
@@ -930,9 +923,10 @@ free_also(also_t *head)
|
|||||||
/*
|
/*
|
||||||
* free the memory used by a starter_conn_t object
|
* free the memory used by a starter_conn_t object
|
||||||
*/
|
*/
|
||||||
static void
|
static void confread_free_conn(starter_conn_t *conn)
|
||||||
confread_free_conn(starter_conn_t *conn)
|
|
||||||
{
|
{
|
||||||
|
free(conn->left.sourceip);
|
||||||
|
free(conn->right.sourceip);
|
||||||
free_args(KW_END_FIRST, KW_END_LAST, (char *)&conn->left);
|
free_args(KW_END_FIRST, KW_END_LAST, (char *)&conn->left);
|
||||||
free_args(KW_END_FIRST, KW_END_LAST, (char *)&conn->right);
|
free_args(KW_END_FIRST, KW_END_LAST, (char *)&conn->right);
|
||||||
free_args(KW_CONN_NAME, KW_CONN_LAST, (char *)conn);
|
free_args(KW_CONN_NAME, KW_CONN_LAST, (char *)conn);
|
||||||
@@ -952,8 +946,7 @@ confread_free_ca(starter_ca_t *ca)
|
|||||||
/*
|
/*
|
||||||
* free the memory used by a starter_config_t object
|
* free the memory used by a starter_config_t object
|
||||||
*/
|
*/
|
||||||
void
|
void confread_free(starter_config_t *cfg)
|
||||||
confread_free(starter_config_t *cfg)
|
|
||||||
{
|
{
|
||||||
starter_conn_t *conn = cfg->conn_first;
|
starter_conn_t *conn = cfg->conn_first;
|
||||||
starter_ca_t *ca = cfg->ca_first;
|
starter_ca_t *ca = cfg->ca_first;
|
||||||
@@ -988,8 +981,7 @@ confread_free(starter_config_t *cfg)
|
|||||||
/*
|
/*
|
||||||
* load and parse an IPsec configuration file
|
* load and parse an IPsec configuration file
|
||||||
*/
|
*/
|
||||||
starter_config_t *
|
starter_config_t* confread_load(const char *file)
|
||||||
confread_load(const char *file)
|
|
||||||
{
|
{
|
||||||
starter_config_t *cfg = NULL;
|
starter_config_t *cfg = NULL;
|
||||||
config_parsed_t *cfgp;
|
config_parsed_t *cfgp;
|
||||||
|
|||||||
Reference in New Issue
Block a user