/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-06-14 02:57:16 UTC
  • mto: (237.7.272 trunk)
  • mto: This revision was merged to the branch mainline in revision 317.
  • Revision ID: teddy@recompile.se-20140614025716-i6887rk3u1iy9l67
In plugin-runner, protect against a larger FD_SETSIZE than fd_set.

* plugin-runner.c (main): Before forking, check that the first FD from
                          pipe() does not exceed FD_SETSIZE.

Show diffs side-by-side

added added

removed removed

Lines of Context:
981
981
      exitstatus = EX_OSERR;
982
982
      goto fallback;
983
983
    }
 
984
    if(pipefd[0] >= FD_SETSIZE){
 
985
      fprintf(stderr, "pipe()[0] (%d) >= FD_SETSIZE (%d)", pipefd[0],
 
986
              FD_SETSIZE);
 
987
      TEMP_FAILURE_RETRY(close(pipefd[0]));
 
988
      TEMP_FAILURE_RETRY(close(pipefd[1]));
 
989
      exitstatus = EX_OSERR;
 
990
      goto fallback;
 
991
    }
984
992
    /* Ask OS to automatic close the pipe on exec */
985
993
    ret = set_cloexec_flag(pipefd[0]);
986
994
    if(ret < 0){
987
995
      error(0, errno, "set_cloexec_flag");
 
996
      TEMP_FAILURE_RETRY(close(pipefd[0]));
 
997
      TEMP_FAILURE_RETRY(close(pipefd[1]));
988
998
      exitstatus = EX_OSERR;
989
999
      goto fallback;
990
1000
    }
991
1001
    ret = set_cloexec_flag(pipefd[1]);
992
1002
    if(ret < 0){
993
1003
      error(0, errno, "set_cloexec_flag");
 
1004
      TEMP_FAILURE_RETRY(close(pipefd[0]));
 
1005
      TEMP_FAILURE_RETRY(close(pipefd[1]));
994
1006
      exitstatus = EX_OSERR;
995
1007
      goto fallback;
996
1008
    }
1010
1022
    } while(pid == -1 and errno == EINTR);
1011
1023
    if(pid == -1){
1012
1024
      error(0, errno, "fork");
 
1025
      TEMP_FAILURE_RETRY(sigprocmask(SIG_UNBLOCK,
 
1026
                                     &sigchld_action.sa_mask, NULL));
 
1027
      TEMP_FAILURE_RETRY(close(pipefd[0]));
 
1028
      TEMP_FAILURE_RETRY(close(pipefd[1]));
1013
1029
      exitstatus = EX_OSERR;
1014
1030
      goto fallback;
1015
1031
    }