starter: Replaced all usages of clone_str() with strdupnull().
authorTobias Brunner <tobias@strongswan.org>
Mon, 14 May 2012 15:50:34 +0000 (17:50 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 11 Jun 2012 15:33:30 +0000 (17:33 +0200)
src/starter/args.c
src/starter/confread.c
src/starter/parser.y

index 3360646..a9a1632 100644 (file)
@@ -312,7 +312,7 @@ char** new_list(char *value)
        char *val, *b, *e, *end, **ret;
        int count;
 
-       val = value ? clone_str(value) : NULL;
+       val = strdupnull(value);
        if (!val)
        {
                return NULL;
@@ -340,7 +340,7 @@ char** new_list(char *value)
                for (e = b; (*e != '\0'); e++);
                if (e != b)
                {
-                       ret[count++] = clone_str(b);
+                       ret[count++] = strdupnull(b);
                }
                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);
 
                        /* assign the new string */
-                       *cp = clone_str(kw->value);
+                       *cp = strdupnull(kw->value);
                }
                break;
        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 **cp2 = (char **)(base2 + token_info[token].offset);
 
-                       *cp1 = clone_str(*cp2);
+                       *cp1 = strdupnull(*cp2);
                }
        }
 }
index d78db5b..e674a6a 100644 (file)
@@ -86,8 +86,8 @@ static void default_values(starter_config_t *cfg)
        cfg->conn_default.policy  = POLICY_ENCRYPT | POLICY_TUNNEL | POLICY_PUBKEY |
                                                                POLICY_PFS | POLICY_MOBIKE;
 
-       cfg->conn_default.ike                   = clone_str(ike_defaults);
-       cfg->conn_default.esp                   = clone_str(esp_defaults);
+       cfg->conn_default.ike                   = strdupnull(ike_defaults);
+       cfg->conn_default.esp                   = strdupnull(esp_defaults);
        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_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;
                                }
                        }
-                       end->host = clone_str(value);
+                       end->host = strdupnull(value);
                }
                break;
        case KW_SUBNET:
@@ -275,7 +275,7 @@ static void kw_end(starter_conn_t *conn, starter_end_t *end, kw_token_t token,
                        else
                        {       /* %poolname, strip %, serve ip requests */
                                free(end->sourceip);
-                               end->sourceip = clone_str(value+1);
+                               end->sourceip = strdupnull(value+1);
                                end->sourceip_mask = 0;
                        }
                        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';
                                free(end->sourceip);
-                               end->sourceip = clone_str(value);
+                               end->sourceip = strdupnull(value);
                                end->sourceip_mask = atoi(pos + 1);
                        }
                        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);
                        goto err;
                }
-               end->subnet = clone_str(value);
+               end->subnet = strdupnull(value);
                break;
        }
        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);
                        goto err;
                }
-               end->sourceip = clone_str(value);
+               end->sourceip = strdupnull(value);
                end->has_natip = TRUE;
                conn->policy |= POLICY_TUNNEL;
                break;
@@ -440,7 +440,7 @@ static void handle_firewall(const char *label, starter_end_t *end,
                }
                else
                {
-                       end->updown = clone_str(firewall_defaults);
+                       end->updown = strdupnull(firewall_defaults);
                        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->name = clone_str(kw->value);
+                               also->name = strdupnull(kw->value);
                                also->next = conn->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)
 {
        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_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->name = clone_str(kw->value);
+                               also->name = strdupnull(kw->value);
                                also->next = ca->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)
 {
        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);
 }
index 9eb09d1..58efeef 100644 (file)
@@ -81,7 +81,7 @@ section_or_include:
        {
                section_list_t *section = malloc_thing(section_list_t);
 
-               section->name = clone_str($2);
+               section->name = strdupnull($2);
                section->kw = NULL;
                section->next = NULL;
                _parser_kw = &(section->kw);
@@ -96,7 +96,7 @@ section_or_include:
        | CA STRING EOL
        {
                section_list_t *section = malloc_thing(section_list_t);
-               section->name = clone_str($2);
+               section->name = strdupnull($2);
                section->kw = NULL;
                section->next = NULL;
                _parser_kw = &(section->kw);
@@ -137,7 +137,7 @@ statement_kw:
                {
                        new = (kw_list_t *)malloc_thing(kw_list_t);
                        new->entry = entry;
-                       new->value = clone_str($3);
+                       new->value = strdupnull($3);
                        new->next = NULL;
                        if (_parser_kw_last)
                                _parser_kw_last->next = new;