final fix for cloning and deleting sourceip strings

This commit is contained in:
Andreas Steffen
2010-05-02 15:55:46 +02:00
parent a48484322e
commit 61e48488d9
2 changed files with 3 additions and 5 deletions
+1 -1
View File
@@ -253,7 +253,7 @@ static const token_info_t token_info[] =
{ ARG_STR, offsetof(starter_end_t, subnet), NULL }, { ARG_STR, offsetof(starter_end_t, subnet), NULL },
{ ARG_MISC, 0, NULL /* KW_SUBNETWITHIN */ }, { ARG_MISC, 0, NULL /* KW_SUBNETWITHIN */ },
{ ARG_MISC, 0, NULL /* KW_PROTOPORT */ }, { ARG_MISC, 0, NULL /* KW_PROTOPORT */ },
{ ARG_MISC, 0, NULL /* KW_SOURCEIP */ }, { ARG_STR, offsetof(starter_end_t, sourceip), NULL },
{ ARG_MISC, 0, NULL /* KW_NATIP */ }, { ARG_MISC, 0, NULL /* KW_NATIP */ },
{ ARG_ENUM, offsetof(starter_end_t, firewall), LST_bool }, { ARG_ENUM, offsetof(starter_end_t, firewall), LST_bool },
{ ARG_ENUM, offsetof(starter_end_t, hostaccess), LST_bool }, { ARG_ENUM, offsetof(starter_end_t, hostaccess), LST_bool },
+2 -4
View File
@@ -194,11 +194,13 @@ static void kw_end(starter_conn_t *conn, starter_end_t *end, kw_token_t token,
streq(value, "%config") || streq(value, "%cfg")) streq(value, "%config") || streq(value, "%cfg"))
{ {
/* request ip via config payload */ /* request ip via config payload */
free(end->sourceip);
end->sourceip = NULL; end->sourceip = NULL;
end->sourceip_mask = 1; end->sourceip_mask = 1;
} }
else else
{ /* %poolname, strip %, serve ip requests */ { /* %poolname, strip %, serve ip requests */
free(end->sourceip);
end->sourceip = clone_str(value+1); end->sourceip = clone_str(value+1);
end->sourceip_mask = 0; end->sourceip_mask = 0;
} }
@@ -222,7 +224,6 @@ static void kw_end(starter_conn_t *conn, starter_end_t *end, kw_token_t token,
goto err; goto err;
} }
*pos = '\0'; *pos = '\0';
end->sourceip = clone_str(value);
end->sourceip_mask = atoi(pos + 1); end->sourceip_mask = atoi(pos + 1);
} }
else else
@@ -233,7 +234,6 @@ static void kw_end(starter_conn_t *conn, starter_end_t *end, kw_token_t token,
plog("# bad addr: %s=%s [%s]", name, value, ugh); plog("# bad addr: %s=%s [%s]", name, value, ugh);
goto err; goto err;
} }
end->sourceip = clone_str(value);
end->sourceip_mask = (conn->tunnel_addr_family == AF_INET) ? end->sourceip_mask = (conn->tunnel_addr_family == AF_INET) ?
32 : 128; 32 : 128;
} }
@@ -925,8 +925,6 @@ static void free_also(also_t *head)
*/ */
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->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);