X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=blobdiff_plain;f=secnet.c;h=f6931b5e36fa0fcf291710842664b71165597890;hb=59230b9b9fc44453f24c6b3cf33a0f4c570a3563;hp=bef236dda9a2b466fad8636e7d51749b7eaaa5e6;hpb=fe5e9cc422cd72526ccfceffbc7e5af8ac83b407;p=secnet.git diff --git a/secnet.c b/secnet.c index bef236d..f6931b5 100644 --- a/secnet.c +++ b/secnet.c @@ -1,7 +1,7 @@ -extern char version[]; - #include "secnet.h" #include +#include +#include #include #include #include @@ -27,14 +27,6 @@ cstring_t require_root_privileges_explanation=NULL; static pid_t secnet_pid; -/* from log.c */ -extern uint32_t message_level; -extern bool_t secnet_is_daemon; -extern struct log_if *system_log; - -/* from process.c */ -extern void start_signal_handling(void); - /* Structures dealing with poll() call */ struct poll_interest { beforepoll_fn *before; @@ -240,6 +232,7 @@ void register_for_poll(void *st, beforepoll_fn *before, i->max_nfds=max_nfds; i->nfds=0; i->desc=desc; + assert(total_nfds < INT_MAX - max_nfds); total_nfds+=max_nfds; i->next=reg; reg=i; @@ -263,10 +256,7 @@ static void run(void) int timeout; struct pollfd *fds; - fds=alloca(sizeof(*fds)*total_nfds); - if (!fds) { - fatal("run: couldn't alloca"); - } + fds=safe_malloc(sizeof(*fds)*total_nfds, "run"); Message(M_NOTICE,"%s [%d]: starting\n",version,secnet_pid); @@ -309,6 +299,7 @@ static void run(void) } } while (rv<0); } while (!finished); + free(fds); } static void droppriv(void)