fixed end->sourceip memory leak in ipsec starter
authorAndreas Steffen <andreas.steffen@strongswan.org>
Sun, 2 May 2010 12:56:35 +0000 (14:56 +0200)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Sun, 2 May 2010 12:56:35 +0000 (14:56 +0200)
src/starter/confread.c

index f71d9b4..c581376 100644 (file)
@@ -107,8 +107,7 @@ static void default_values(starter_config_t *cfg)
                else if (streq(kw->value, sn)) { conn->policy &= ~fl; } \
                else { plog("# bad policy value: %s=%s", kw->entry->name, kw->value); cfg->err++; }
 
-static void
-load_setup(starter_config_t *cfg, config_parsed_t *cfgp)
+static void load_setup(starter_config_t *cfg, config_parsed_t *cfgp)
 {
        kw_list_t *kw;
 
@@ -421,8 +420,8 @@ err:
 /*
  * handles left|right=<FQDN> DNS resolution failure
  */
-static void
-handle_dns_failure( const char *label, starter_end_t *end, starter_config_t *cfg)
+static void handle_dns_failure(const char *label, starter_end_t *end,
+                                                          starter_config_t *cfg)
 {
        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
  */
-static void
-handle_firewall( const char *label, starter_end_t *end, starter_config_t *cfg)
+static void handle_firewall(const char *label, starter_end_t *end,
+                                                       starter_config_t *cfg)
 {
        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
  */
-static void
-load_conn(starter_conn_t *conn, kw_list_t *kw, starter_config_t *cfg)
+static void load_conn(starter_conn_t *conn, kw_list_t *kw, starter_config_t *cfg)
 {
        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
  */
-static void
-conn_default(char *name, starter_conn_t *conn, starter_conn_t *def)
+static void conn_default(char *name, starter_conn_t *conn, starter_conn_t *def)
 {
        memcpy(conn, def, sizeof(starter_conn_t));
        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
  */
-static void
-load_ca(starter_ca_t *ca, kw_list_t *kw, starter_config_t *cfg)
+static void load_ca(starter_ca_t *ca, kw_list_t *kw, starter_config_t *cfg)
 {
        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
  */
-static void
-ca_default(char *name, starter_ca_t *ca, starter_ca_t *def)
+static void ca_default(char *name, starter_ca_t *ca, starter_ca_t *def)
 {
        memcpy(ca, def, sizeof(starter_ca_t));
        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);
 }
 
-static kw_list_t*
-find_also_conn(const char* name, starter_conn_t *conn, starter_config_t *cfg);
+static kw_list_t* find_also_conn(const char* name, starter_conn_t *conn,
+                                                                starter_config_t *cfg);
 
-static void
-load_also_conns(starter_conn_t *conn, also_t *also, starter_config_t *cfg)
+static void load_also_conns(starter_conn_t *conn, also_t *also,
+                                                       starter_config_t *cfg)
 {
        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
  */
-static kw_list_t*
-find_also_conn(const char* name, starter_conn_t *conn, starter_config_t *cfg)
+static kw_list_t* find_also_conn(const char* name, starter_conn_t *conn, 
+                                                                starter_config_t *cfg)
 {
        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;
 }
 
-static kw_list_t*
-find_also_ca(const char* name, starter_ca_t *ca, starter_config_t *cfg);
+static kw_list_t* find_also_ca(const char* name, starter_ca_t *ca,
+                                                          starter_config_t *cfg);
 
-static void
-load_also_cas(starter_ca_t *ca, also_t *also, starter_config_t *cfg)
+static void load_also_cas(starter_ca_t *ca, also_t *also, starter_config_t *cfg)
 {
        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
  */
-static kw_list_t*
-find_also_ca(const char* name, starter_ca_t *ca, starter_config_t *cfg)
+static kw_list_t* find_also_ca(const char* name, starter_ca_t *ca,
+                                                          starter_config_t *cfg)
 {
        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
  */
-static void
-free_also(also_t *head)
+static void free_also(also_t *head)
 {
        while (head != NULL)
        {
@@ -930,9 +923,10 @@ free_also(also_t *head)
 /*
  * free the memory used by a starter_conn_t object
  */
-static void
-confread_free_conn(starter_conn_t *conn)
+static void 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->right);
        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
  */
-void
-confread_free(starter_config_t *cfg)
+void confread_free(starter_config_t *cfg)
 {
        starter_conn_t *conn = cfg->conn_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
  */
-starter_config_t *
-confread_load(const char *file)
+starter_config_t* confread_load(const char *file)
 {
        starter_config_t *cfg = NULL;
        config_parsed_t  *cfgp;