summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@intec.ugent.be>2017-01-29 13:17:33 +0100
committerdimitri staessens <dimitri.staessens@intec.ugent.be>2017-01-29 13:23:38 +0100
commit1f94baea43c031c366decb9c772514a89a7fa372 (patch)
tree14c3f3aa49f62706d5bcf7cd5e87698956a9a599 /src
parentcfc1e421cd222f41dd1c8498d631a31c680e4211 (diff)
downloadouroboros-1f94baea43c031c366decb9c772514a89a7fa372.tar.gz
ouroboros-1f94baea43c031c366decb9c772514a89a7fa372.zip
ipcpd: Don't strdup() the dif_name in main loop
Diffstat (limited to 'src')
-rw-r--r--src/ipcpd/ipcp.c4
-rw-r--r--src/ipcpd/local/main.c3
-rw-r--r--src/ipcpd/normal/main.c9
-rw-r--r--src/ipcpd/shim-eth-llc/main.c3
-rw-r--r--src/ipcpd/shim-udp/main.c3
5 files changed, 8 insertions, 14 deletions
diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c
index a94e268d..2c3beed7 100644
--- a/src/ipcpd/ipcp.c
+++ b/src/ipcpd/ipcp.c
@@ -110,7 +110,7 @@ static void * ipcp_main_loop(void * o)
}
conf_msg = msg->conf;
conf.type = conf_msg->ipcp_type;
- conf.dif_name = strdup(conf_msg->dif_name);
+ conf.dif_name = conf_msg->dif_name;
if (conf.dif_name == NULL) {
ret_msg.has_result = true;
ret_msg.result = -1;
@@ -139,8 +139,6 @@ static void * ipcp_main_loop(void * o)
ret_msg.has_result = true;
ret_msg.result = ipcpi.ops->ipcp_bootstrap(&conf);
- if (ret_msg.result < 0)
- free(conf.dif_name);
break;
case IPCP_MSG_CODE__IPCP_ENROLL:
if (ipcpi.ops->ipcp_enroll == NULL) {
diff --git a/src/ipcpd/local/main.c b/src/ipcpd/local/main.c
index 5117f59d..2448c3a4 100644
--- a/src/ipcpd/local/main.c
+++ b/src/ipcpd/local/main.c
@@ -153,9 +153,6 @@ static int ipcp_local_bootstrap(struct dif_config * conf)
return -1;
}
- /* this IPCP doesn't need to maintain its dif_name */
- free(conf->dif_name);
-
ipcp_set_state(IPCP_OPERATIONAL);
pthread_create(&local_data.sduloop, NULL, ipcp_local_sdu_loop, NULL);
diff --git a/src/ipcpd/normal/main.c b/src/ipcpd/normal/main.c
index 85f56ab0..c1bae0d6 100644
--- a/src/ipcpd/normal/main.c
+++ b/src/ipcpd/normal/main.c
@@ -218,6 +218,13 @@ static int normal_ipcp_bootstrap(struct dif_config * conf)
return -1; /* -ENOTINIT */
}
+ ipcpi.data->dif_name = strdup(conf->dif_name);
+ if (ipcpi.data->dif_name == NULL) {
+ pthread_rwlock_unlock(&ipcpi.state_lock);
+ LOG_ERR("Failed to set DIF name.");
+ return -1;
+ }
+
if (ribmgr_init()) {
LOG_ERR("Failed to initialise RIB manager.");
pthread_rwlock_unlock(&ipcpi.state_lock);
@@ -273,8 +280,6 @@ static int normal_ipcp_bootstrap(struct dif_config * conf)
return -1;
}
- ipcpi.data->dif_name = conf->dif_name;
-
pthread_rwlock_unlock(&ipcpi.state_lock);
LOG_DBG("Bootstrapped in DIF %s.", conf->dif_name);
diff --git a/src/ipcpd/shim-eth-llc/main.c b/src/ipcpd/shim-eth-llc/main.c
index da496b07..c59a8054 100644
--- a/src/ipcpd/shim-eth-llc/main.c
+++ b/src/ipcpd/shim-eth-llc/main.c
@@ -857,9 +857,6 @@ static int eth_llc_ipcp_bootstrap(struct dif_config * conf)
pthread_rwlock_unlock(&ipcpi.state_lock);
- /* this IPCP doesn't need to maintain its dif_name */
- free(conf->dif_name);
-
LOG_DBG("Bootstrapped shim IPCP over Ethernet with LLC with api %d.",
getpid());
diff --git a/src/ipcpd/shim-udp/main.c b/src/ipcpd/shim-udp/main.c
index 99aac40e..e9c15579 100644
--- a/src/ipcpd/shim-udp/main.c
+++ b/src/ipcpd/shim-udp/main.c
@@ -635,9 +635,6 @@ static int ipcp_udp_bootstrap(struct dif_config * conf)
pthread_rwlock_unlock(&ipcpi.state_lock);
- /* this IPCP doesn't need to maintain its dif_name */
- free(conf->dif_name);
-
LOG_DBG("Bootstrapped shim IPCP over UDP with api %d.", getpid());
LOG_DBG("Bound to IP address %s.", ipstr);
LOG_DBG("DNS server address is %s.", dnsstr);