summaryrefslogtreecommitdiff
path: root/src/ipcpd
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@intec.ugent.be>2016-08-22 11:39:46 +0200
committerSander Vrijders <sander.vrijders@intec.ugent.be>2016-08-22 11:39:46 +0200
commitf99731a667b2ba5aa8ac7f1b331e03e7ad62e7c7 (patch)
tree2ca0e58bbf99625599f431761248771eb47bee78 /src/ipcpd
parente2fd96f11b6a90d92f2d33627cb57ebf266e62ef (diff)
parent9c946366fcd477b285b4421c324162a10aa300b6 (diff)
downloadouroboros-f99731a667b2ba5aa8ac7f1b331e03e7ad62e7c7.tar.gz
ouroboros-f99731a667b2ba5aa8ac7f1b331e03e7ad62e7c7.zip
Merged in dstaesse/ouroboros/be-fix (pull request #215)
Fix potential memleaks in ipcp.c
Diffstat (limited to 'src/ipcpd')
-rw-r--r--src/ipcpd/ipcp.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c
index cc77af89..4f3e6799 100644
--- a/src/ipcpd/ipcp.c
+++ b/src/ipcpd/ipcp.c
@@ -127,6 +127,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 +189,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 +218,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 +235,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) {