/mandos/release

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

« back to all changes in this revision

Viewing changes to plugin-runner.c

  • Committer: Teddy Hogeborn
  • Date: 2014-07-15 19:35:03 UTC
  • mto: (237.7.272 trunk)
  • mto: This revision was merged to the branch mainline in revision 319.
  • Revision ID: teddy@recompile.se-20140715193503-e18hls7m4rv4l6iq
mandos-client: Fix mem free bug.

* plugins.d/mandos-client.c (add_server): Hide warning.
  (main): Free server->ip too, not just the server struct.

Show diffs side-by-side

added added

removed removed

Lines of Context:
887
887
    int plugin_fd = openat(dir_fd, direntries[i]->d_name, O_RDONLY);
888
888
    if(plugin_fd == -1){
889
889
      error(0, errno, "Could not open plugin");
890
 
      free(direntries[i]);
891
890
      continue;
892
891
    }
893
892
    ret = (int)TEMP_FAILURE_RETRY(fstat(plugin_fd, &st));
894
893
    if(ret == -1){
895
894
      error(0, errno, "stat");
896
895
      TEMP_FAILURE_RETRY(close(plugin_fd));
897
 
      free(direntries[i]);
898
896
      continue;
899
897
    }
900
898
    
909
907
                direntries[i]->d_name);
910
908
      }
911
909
      TEMP_FAILURE_RETRY(close(plugin_fd));
912
 
      free(direntries[i]);
913
910
      continue;
914
911
    }
915
912
    
917
914
    if(p == NULL){
918
915
      error(0, errno, "getplugin");
919
916
      TEMP_FAILURE_RETRY(close(plugin_fd));
920
 
      free(direntries[i]);
921
917
      continue;
922
918
    }
923
919
    if(p->disabled){
926
922
                direntries[i]->d_name);
927
923
      }
928
924
      TEMP_FAILURE_RETRY(close(plugin_fd));
929
 
      free(direntries[i]);
930
925
      continue;
931
926
    }
932
927
    {
965
960
    if(ret == -1){
966
961
      error(0, errno, "pipe");
967
962
      exitstatus = EX_OSERR;
968
 
      free(direntries[i]);
969
963
      goto fallback;
970
964
    }
971
965
    if(pipefd[0] >= FD_SETSIZE){
974
968
      TEMP_FAILURE_RETRY(close(pipefd[0]));
975
969
      TEMP_FAILURE_RETRY(close(pipefd[1]));
976
970
      exitstatus = EX_OSERR;
977
 
      free(direntries[i]);
978
971
      goto fallback;
979
972
    }
980
973
#ifndef O_CLOEXEC
985
978
      TEMP_FAILURE_RETRY(close(pipefd[0]));
986
979
      TEMP_FAILURE_RETRY(close(pipefd[1]));
987
980
      exitstatus = EX_OSERR;
988
 
      free(direntries[i]);
989
981
      goto fallback;
990
982
    }
991
983
    ret = set_cloexec_flag(pipefd[1]);
994
986
      TEMP_FAILURE_RETRY(close(pipefd[0]));
995
987
      TEMP_FAILURE_RETRY(close(pipefd[1]));
996
988
      exitstatus = EX_OSERR;
997
 
      free(direntries[i]);
998
989
      goto fallback;
999
990
    }
1000
991
#endif  /* not O_CLOEXEC */
1005
996
    if(ret < 0){
1006
997
      error(0, errno, "sigprocmask");
1007
998
      exitstatus = EX_OSERR;
1008
 
      free(direntries[i]);
1009
999
      goto fallback;
1010
1000
    }
1011
1001
    /* Starting a new process to be watched */
1020
1010
      TEMP_FAILURE_RETRY(close(pipefd[0]));
1021
1011
      TEMP_FAILURE_RETRY(close(pipefd[1]));
1022
1012
      exitstatus = EX_OSERR;
1023
 
      free(direntries[i]);
1024
1013
      goto fallback;
1025
1014
    }
1026
1015
    if(pid == 0){
1065
1054
        error(0, errno, "sigprocmask");
1066
1055
      }
1067
1056
      exitstatus = EX_OSERR;
1068
 
      free(direntries[i]);
1069
1057
      goto fallback;
1070
1058
    }
1071
 
    free(direntries[i]);
1072
1059
    
1073
1060
    new_plugin->pid = pid;
1074
1061
    new_plugin->fd = pipefd[0];