chiark / gitweb /
integer and buffer overflows: introduce a number of asserts
[secnet.git] / secnet.c
index efe52b356048bc2e44ca0ac93939bd6edae90bf0..f6931b5e36fa0fcf291710842664b71165597890 100644 (file)
--- a/secnet.c
+++ b/secnet.c
@@ -1,7 +1,7 @@
-extern char version[];
-
 #include "secnet.h"
 #include <stdio.h>
+#include <assert.h>
+#include <limits.h>
 #include <string.h>
 #include <getopt.h>
 #include <errno.h>
@@ -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;