summaryrefslogtreecommitdiff
path: root/src/ipcpd/ipcp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ipcpd/ipcp.c')
-rw-r--r--src/ipcpd/ipcp.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c
index cc77af89..1c4fab94 100644
--- a/src/ipcpd/ipcp.c
+++ b/src/ipcpd/ipcp.c
@@ -103,7 +103,13 @@ int ipcp_parse_arg(int argc, char * argv[])
static void close_ptr(void * o)
{
+ char * name = ipcp_sock_path(getpid());
close(*((int *) o));
+
+ if (unlink(name))
+ LOG_DBG("Could not unlink %s.", name);
+
+ free(name);
}
static void clean_msg(void * msg)
@@ -127,6 +133,7 @@ void * ipcp_main_loop(void * o)
struct dif_config conf;
char * sock_path;
+ char * msg_name_dup;
struct timeval tv = {(SOCKET_TIMEOUT / 1000),
(SOCKET_TIMEOUT % 1000) * 1000};
@@ -188,7 +195,7 @@ void * ipcp_main_loop(void * o)
}
conf_msg = msg->conf;
conf.type = conf_msg->ipcp_type;
- conf.dif_name = conf_msg->dif_name;
+ conf.dif_name = strdup(conf_msg->dif_name);
if (conf.dif_name == NULL) {
ret_msg.has_result = true;
ret_msg.result = -1;
@@ -217,6 +224,8 @@ void * ipcp_main_loop(void * o)
ret_msg.has_result = true;
ret_msg.result = _ipcp->ops->ipcp_bootstrap(&conf);
+ if (ret_msg.result < 0)
+ free(conf.dif_name);
break;
case IPCP_MSG_CODE__IPCP_ENROLL:
if (_ipcp->ops->ipcp_enroll == NULL) {
@@ -232,9 +241,12 @@ void * ipcp_main_loop(void * o)
LOG_ERR("Ap_reg unsupported.");
break;
}
+ msg_name_dup = strdup(msg->name);
ret_msg.has_result = true;
ret_msg.result =
- _ipcp->ops->ipcp_name_reg(strdup(msg->name));
+ _ipcp->ops->ipcp_name_reg(msg_name_dup);
+ if (ret_msg.result < 0)
+ free(msg_name_dup);
break;
case IPCP_MSG_CODE__IPCP_NAME_UNREG:
if (_ipcp->ops->ipcp_name_unreg == NULL) {