starter: Replaced all usages of clone_str() with strdupnull().

This commit is contained in:
Tobias Brunner
2012-06-11 17:33:30 +02:00
parent e838c39ba9
commit 7cce0e96f2
3 changed files with 19 additions and 19 deletions
+4 -4
View File
@@ -312,7 +312,7 @@ char** new_list(char *value)
char *val, *b, *e, *end, **ret; char *val, *b, *e, *end, **ret;
int count; int count;
val = value ? clone_str(value) : NULL; val = strdupnull(value);
if (!val) if (!val)
{ {
return NULL; return NULL;
@@ -340,7 +340,7 @@ char** new_list(char *value)
for (e = b; (*e != '\0'); e++); for (e = b; (*e != '\0'); e++);
if (e != b) if (e != b)
{ {
ret[count++] = clone_str(b); ret[count++] = strdupnull(b);
} }
b = e + 1; b = e + 1;
} }
@@ -522,7 +522,7 @@ bool assign_arg(kw_token_t token, kw_token_t first, kw_list_t *kw, char *base,
free(*cp); free(*cp);
/* assign the new string */ /* assign the new string */
*cp = clone_str(kw->value); *cp = strdupnull(kw->value);
} }
break; break;
case ARG_LST: case ARG_LST:
@@ -622,7 +622,7 @@ void clone_args(kw_token_t first, kw_token_t last, char *base1, char *base2)
char **cp1 = (char **)(base1 + token_info[token].offset); char **cp1 = (char **)(base1 + token_info[token].offset);
char **cp2 = (char **)(base2 + token_info[token].offset); char **cp2 = (char **)(base2 + token_info[token].offset);
*cp1 = clone_str(*cp2); *cp1 = strdupnull(*cp2);
} }
} }
} }
+12 -12
View File
@@ -86,8 +86,8 @@ static void default_values(starter_config_t *cfg)
cfg->conn_default.policy = POLICY_ENCRYPT | POLICY_TUNNEL | POLICY_PUBKEY | cfg->conn_default.policy = POLICY_ENCRYPT | POLICY_TUNNEL | POLICY_PUBKEY |
POLICY_PFS | POLICY_MOBIKE; POLICY_PFS | POLICY_MOBIKE;
cfg->conn_default.ike = clone_str(ike_defaults); cfg->conn_default.ike = strdupnull(ike_defaults);
cfg->conn_default.esp = clone_str(esp_defaults); cfg->conn_default.esp = strdupnull(esp_defaults);
cfg->conn_default.sa_ike_life_seconds = OAKLEY_ISAKMP_SA_LIFETIME_DEFAULT; cfg->conn_default.sa_ike_life_seconds = OAKLEY_ISAKMP_SA_LIFETIME_DEFAULT;
cfg->conn_default.sa_ipsec_life_seconds = PLUTO_SA_LIFE_DURATION_DEFAULT; cfg->conn_default.sa_ipsec_life_seconds = PLUTO_SA_LIFE_DURATION_DEFAULT;
cfg->conn_default.sa_rekey_margin = SA_REPLACEMENT_MARGIN_DEFAULT; cfg->conn_default.sa_rekey_margin = SA_REPLACEMENT_MARGIN_DEFAULT;
@@ -224,7 +224,7 @@ static void kw_end(starter_conn_t *conn, starter_end_t *end, kw_token_t token,
goto err; goto err;
} }
} }
end->host = clone_str(value); end->host = strdupnull(value);
} }
break; break;
case KW_SUBNET: case KW_SUBNET:
@@ -275,7 +275,7 @@ static void kw_end(starter_conn_t *conn, starter_end_t *end, kw_token_t token,
else else
{ /* %poolname, strip %, serve ip requests */ { /* %poolname, strip %, serve ip requests */
free(end->sourceip); free(end->sourceip);
end->sourceip = clone_str(value+1); end->sourceip = strdupnull(value+1);
end->sourceip_mask = 0; end->sourceip_mask = 0;
} }
end->modecfg = TRUE; end->modecfg = TRUE;
@@ -299,7 +299,7 @@ static void kw_end(starter_conn_t *conn, starter_end_t *end, kw_token_t token,
} }
*pos = '\0'; *pos = '\0';
free(end->sourceip); free(end->sourceip);
end->sourceip = clone_str(value); end->sourceip = strdupnull(value);
end->sourceip_mask = atoi(pos + 1); end->sourceip_mask = atoi(pos + 1);
} }
else else
@@ -366,7 +366,7 @@ static void kw_end(starter_conn_t *conn, starter_end_t *end, kw_token_t token,
DBG1(DBG_APP, "# bad subnet: %s=%s [%s]", name, value, ugh); DBG1(DBG_APP, "# bad subnet: %s=%s [%s]", name, value, ugh);
goto err; goto err;
} }
end->subnet = clone_str(value); end->subnet = strdupnull(value);
break; break;
} }
case KW_PROTOPORT: case KW_PROTOPORT:
@@ -388,7 +388,7 @@ static void kw_end(starter_conn_t *conn, starter_end_t *end, kw_token_t token,
DBG1(DBG_APP, "# bad addr: %s=%s [%s]", name, value, ugh); DBG1(DBG_APP, "# bad addr: %s=%s [%s]", name, value, ugh);
goto err; goto err;
} }
end->sourceip = clone_str(value); end->sourceip = strdupnull(value);
end->has_natip = TRUE; end->has_natip = TRUE;
conn->policy |= POLICY_TUNNEL; conn->policy |= POLICY_TUNNEL;
break; break;
@@ -440,7 +440,7 @@ static void handle_firewall(const char *label, starter_end_t *end,
} }
else else
{ {
end->updown = clone_str(firewall_defaults); end->updown = strdupnull(firewall_defaults);
end->firewall = FALSE; end->firewall = FALSE;
} }
} }
@@ -517,7 +517,7 @@ static void load_conn(starter_conn_t *conn, kw_list_t *kw, starter_config_t *cfg
{ {
also_t *also = malloc_thing(also_t); also_t *also = malloc_thing(also_t);
also->name = clone_str(kw->value); also->name = strdupnull(kw->value);
also->next = conn->also; also->next = conn->also;
conn->also = also; conn->also = also;
@@ -679,7 +679,7 @@ static void load_conn(starter_conn_t *conn, kw_list_t *kw, starter_config_t *cfg
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)); memcpy(conn, def, sizeof(starter_conn_t));
conn->name = clone_str(name); conn->name = strdupnull(name);
clone_args(KW_CONN_FIRST, KW_CONN_LAST, (char *)conn, (char *)def); clone_args(KW_CONN_FIRST, KW_CONN_LAST, (char *)conn, (char *)def);
clone_args(KW_END_FIRST, KW_END_LAST, (char *)&conn->left, (char *)&def->left); clone_args(KW_END_FIRST, KW_END_LAST, (char *)&conn->left, (char *)&def->left);
@@ -709,7 +709,7 @@ static void load_ca(starter_ca_t *ca, kw_list_t *kw, starter_config_t *cfg)
{ {
also_t *also = malloc_thing(also_t); also_t *also = malloc_thing(also_t);
also->name = clone_str(kw->value); also->name = strdupnull(kw->value);
also->next = ca->also; also->next = ca->also;
ca->also = also; ca->also = also;
@@ -744,7 +744,7 @@ static void load_ca(starter_ca_t *ca, kw_list_t *kw, starter_config_t *cfg)
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)); memcpy(ca, def, sizeof(starter_ca_t));
ca->name = clone_str(name); ca->name = strdupnull(name);
clone_args(KW_CA_FIRST, KW_CA_LAST, (char *)ca, (char *)def); clone_args(KW_CA_FIRST, KW_CA_LAST, (char *)ca, (char *)def);
} }
+3 -3
View File
@@ -81,7 +81,7 @@ section_or_include:
{ {
section_list_t *section = malloc_thing(section_list_t); section_list_t *section = malloc_thing(section_list_t);
section->name = clone_str($2); section->name = strdupnull($2);
section->kw = NULL; section->kw = NULL;
section->next = NULL; section->next = NULL;
_parser_kw = &(section->kw); _parser_kw = &(section->kw);
@@ -96,7 +96,7 @@ section_or_include:
| CA STRING EOL | CA STRING EOL
{ {
section_list_t *section = malloc_thing(section_list_t); section_list_t *section = malloc_thing(section_list_t);
section->name = clone_str($2); section->name = strdupnull($2);
section->kw = NULL; section->kw = NULL;
section->next = NULL; section->next = NULL;
_parser_kw = &(section->kw); _parser_kw = &(section->kw);
@@ -137,7 +137,7 @@ statement_kw:
{ {
new = (kw_list_t *)malloc_thing(kw_list_t); new = (kw_list_t *)malloc_thing(kw_list_t);
new->entry = entry; new->entry = entry;
new->value = clone_str($3); new->value = strdupnull($3);
new->next = NULL; new->next = NULL;
if (_parser_kw_last) if (_parser_kw_last)
_parser_kw_last->next = new; _parser_kw_last->next = new;