diff options
Diffstat (limited to 'src/ipcpd')
| -rw-r--r-- | src/ipcpd/ipcp.c | 7 | ||||
| -rw-r--r-- | src/ipcpd/local/main.c | 9 | ||||
| -rw-r--r-- | src/ipcpd/normal/dir.c | 2 | ||||
| -rw-r--r-- | src/ipcpd/shim-eth-llc/main.c | 9 | ||||
| -rw-r--r-- | src/ipcpd/shim-udp/main.c | 10 | 
5 files changed, 26 insertions, 11 deletions
| diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c index 2c3beed7..2115f7c1 100644 --- a/src/ipcpd/ipcp.c +++ b/src/ipcpd/ipcp.c @@ -49,8 +49,6 @@ static void * ipcp_main_loop(void * o)          dif_config_msg_t * conf_msg;          struct dif_config  conf; -        char * msg_name_dup; -          struct timeval ltv = {(SOCKET_TIMEOUT / 1000),                               (SOCKET_TIMEOUT % 1000) * 1000}; @@ -154,12 +152,9 @@ static 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 = -                                ipcpi.ops->ipcp_name_reg(msg_name_dup); -                        if (ret_msg.result < 0) -                                free(msg_name_dup); +                                ipcpi.ops->ipcp_name_reg(msg->name);                          break;                  case IPCP_MSG_CODE__IPCP_NAME_UNREG:                          if (ipcpi.ops->ipcp_name_unreg == NULL) { diff --git a/src/ipcpd/local/main.c b/src/ipcpd/local/main.c index 73c22975..c2b22732 100644 --- a/src/ipcpd/local/main.c +++ b/src/ipcpd/local/main.c @@ -168,11 +168,18 @@ static int ipcp_local_bootstrap(struct dif_config * conf)  static int ipcp_local_name_reg(char * name)  { +        char * name_dup = strdup(name); +        if (name_dup == NULL) { +                LOG_ERR("Failed to duplicate name."); +                return -ENOMEM; +        } +          pthread_rwlock_rdlock(&ipcpi.state_lock); -        if (ipcp_data_reg_add_entry(ipcpi.data, name)) { +        if (ipcp_data_reg_add_entry(ipcpi.data, name_dup)) {                  pthread_rwlock_unlock(&ipcpi.state_lock);                  LOG_DBG("Failed to add %s to local registry.", name); +                free(name_dup);                  return -1;          } diff --git a/src/ipcpd/normal/dir.c b/src/ipcpd/normal/dir.c index d9d15f72..49283529 100644 --- a/src/ipcpd/normal/dir.c +++ b/src/ipcpd/normal/dir.c @@ -123,8 +123,6 @@ int dir_name_reg(char * name)          LOG_DBG("Registered %s.", name);          pathname_destroy(path); -        free(name); -          return 0;  } diff --git a/src/ipcpd/shim-eth-llc/main.c b/src/ipcpd/shim-eth-llc/main.c index c59a8054..bc0d8a27 100644 --- a/src/ipcpd/shim-eth-llc/main.c +++ b/src/ipcpd/shim-eth-llc/main.c @@ -865,11 +865,18 @@ static int eth_llc_ipcp_bootstrap(struct dif_config * conf)  static int eth_llc_ipcp_name_reg(char * name)  { +        char * name_dup = strdup(name); +        if (name_dup == NULL) { +                LOG_ERR("Failed to duplicate name."); +                return -ENOMEM; +        } +          pthread_rwlock_rdlock(&ipcpi.state_lock); -        if (ipcp_data_reg_add_entry(ipcpi.data, name)) { +        if (ipcp_data_reg_add_entry(ipcpi.data, name_dup)) {                  pthread_rwlock_unlock(&ipcpi.state_lock);                  LOG_ERR("Failed to add %s to local registry.", name); +                free(name_dup);                  return -1;          } diff --git a/src/ipcpd/shim-udp/main.c b/src/ipcpd/shim-udp/main.c index e9c15579..c2f86067 100644 --- a/src/ipcpd/shim-udp/main.c +++ b/src/ipcpd/shim-udp/main.c @@ -776,17 +776,25 @@ static int ipcp_udp_name_reg(char * name)          uint32_t dns_addr;          uint32_t ip_addr;  #endif +        char * name_dup;          if (strlen(name) > 24) {                  LOG_ERR("DNS names cannot be longer than 24 chars.");                  return -1;          } +        name_dup = strdup(name); +        if (name_dup == NULL) { +                LOG_ERR("Failed to duplicate name."); +                return -ENOMEM; +        } +          pthread_rwlock_rdlock(&ipcpi.state_lock); -        if (ipcp_data_reg_add_entry(ipcpi.data, name)) { +        if (ipcp_data_reg_add_entry(ipcpi.data, name_dup)) {                  pthread_rwlock_unlock(&ipcpi.state_lock);                  LOG_ERR("Failed to add %s to local registry.", name); +                free(name_dup);                  return -1;          } | 
