/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to plugins.d/mandos-client.c

  • Committer: Teddy Hogeborn
  • Date: 2014-07-15 23:52:00 UTC
  • Revision ID: teddy@recompile.se-20140715235200-4dukd7i2tvbcix61
mandos-client: Bug Fix: Fix some memory leaks.

* plugins.d/mandos-client.c (resolve_callback): Always free resolver.
  (run_network_hooks): Free the individual direntries.
  (main): When listing network interfaces and when removing the GPGME
          temp directory, free the individual direntries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1076
1076
     timed out */
1077
1077
  
1078
1078
  if(quit_now){
 
1079
    avahi_s_service_resolver_free(r);
1079
1080
    return;
1080
1081
  }
1081
1082
  
1652
1653
      int status;
1653
1654
      if(TEMP_FAILURE_RETRY(waitpid(hook_pid, &status, 0)) == -1){
1654
1655
        perror_plus("waitpid");
 
1656
        free(direntry);
1655
1657
        continue;
1656
1658
      }
1657
1659
      if(WIFEXITED(status)){
1659
1661
          fprintf_plus(stderr, "Warning: network hook \"%s\" exited"
1660
1662
                       " with status %d\n", direntry->d_name,
1661
1663
                       WEXITSTATUS(status));
 
1664
          free(direntry);
1662
1665
          continue;
1663
1666
        }
1664
1667
      } else if(WIFSIGNALED(status)){
1665
1668
        fprintf_plus(stderr, "Warning: network hook \"%s\" died by"
1666
1669
                     " signal %d\n", direntry->d_name,
1667
1670
                     WTERMSIG(status));
 
1671
        free(direntry);
1668
1672
        continue;
1669
1673
      } else {
1670
1674
        fprintf_plus(stderr, "Warning: network hook \"%s\""
1671
1675
                     " crashed\n", direntry->d_name);
 
1676
        free(direntry);
1672
1677
        continue;
1673
1678
      }
1674
1679
    }
1676
1681
      fprintf_plus(stderr, "Network hook \"%s\" ran successfully\n",
1677
1682
                   direntry->d_name);
1678
1683
    }
 
1684
    free(direntry);
1679
1685
  }
1680
1686
  free(direntries);
1681
1687
  if((int)TEMP_FAILURE_RETRY(close(hookdir_fd)) == -1){
2275
2281
        if(ret_errno != 0){
2276
2282
          errno = ret_errno;
2277
2283
          perror_plus("argz_add");
 
2284
          free(direntries[i]);
2278
2285
          continue;
2279
2286
        }
2280
2287
        if(debug){
2281
2288
          fprintf_plus(stderr, "Will use interface \"%s\"\n",
2282
2289
                       direntries[i]->d_name);
2283
2290
        }
 
2291
        free(direntries[i]);
2284
2292
      }
2285
2293
      free(direntries);
2286
2294
    } else {
2638
2646
                         " \"%s\", 0): %s\n", tempdir,
2639
2647
                         direntries[i]->d_name, strerror(errno));
2640
2648
          }
 
2649
          free(direntries[i]);
2641
2650
        }
2642
2651
        
2643
2652
        /* need to clean even if 0 because man page doesn't specify */