diff options
| author | Sander Vrijders <sander.vrijders@ugent.be> | 2017-08-23 12:46:04 +0200 | 
|---|---|---|
| committer | Sander Vrijders <sander.vrijders@ugent.be> | 2017-08-23 12:53:27 +0200 | 
| commit | 2f215b5c3139a0cb05d4db3cf8b3c8a2ee8bf9dc (patch) | |
| tree | 168a6e56a34bfd7e08b71c36d48f228eeb1f6cec /src/irmd | |
| parent | 45c77a507ed275830633849f368c4ed5b4831328 (diff) | |
| download | ouroboros-2f215b5c3139a0cb05d4db3cf8b3c8a2ee8bf9dc.tar.gz ouroboros-2f215b5c3139a0cb05d4db3cf8b3c8a2ee8bf9dc.zip | |
irmd: Fix potential data race in irmd
If the IPCP was not created, the printing of the log may use a
variable that was already freed.
Diffstat (limited to 'src/irmd')
| -rw-r--r-- | src/irmd/main.c | 8 | 
1 files changed, 5 insertions, 3 deletions
| diff --git a/src/irmd/main.c b/src/irmd/main.c index 62c1cc61..a7c2bd4c 100644 --- a/src/irmd/main.c +++ b/src/irmd/main.c @@ -292,6 +292,7 @@ static pid_t create_ipcp(char *         name,          struct timespec     dl;          struct timespec     to = {SOCKET_TIMEOUT / 1000,                                    (SOCKET_TIMEOUT % 1000) * MILLION}; +        pid_t               ipcp_pid;          api = malloc(sizeof(*api));          if (api == NULL) @@ -344,6 +345,7 @@ static pid_t create_ipcp(char *         name,          tmp->type          = ipcp_type;          tmp->init_state    = IPCP_BOOT;          tmp->dir_hash_algo = -1; +        ipcp_pid           = tmp->api;          list_for_each(p, &irmd.ipcps) {                  struct ipcp_entry * e = list_entry(p, struct ipcp_entry, next); @@ -372,15 +374,15 @@ static pid_t create_ipcp(char *         name,                  tmp->init_state = IPCP_NULL;                  pthread_cond_signal(&tmp->init_cond);                  pthread_mutex_unlock(&tmp->init_lock); -                log_err("IPCP %d failed to respond.", tmp->api); +                log_err("IPCP %d failed to respond.", ipcp_pid);                  return -1;          }          pthread_mutex_unlock(&tmp->init_lock); -        log_info("Created IPCP %d.", tmp->api); +        log_info("Created IPCP %d.", ipcp_pid); -        return api->pid; +        return ipcp_pid;  }  static int create_ipcp_r(pid_t api, | 
