Code

Fix buffer overflow vulnerabilities when parsing HTTP redirect
[nagiosplug.git] / plugins / common.h
index b3357431a5d7ce4f4dba7359d049292fb370f9ed..752e21fffe4ab2a67a5a5eea0750d4883bb74a1c 100644 (file)
 #include <unistd.h>
 #endif
 
+/* GET_NUMBER_OF_CPUS is a macro to return 
+   number of CPUs, if we can get that data.
+   Use configure.in to test for various OS ways of
+   getting that data
+   Will return -1 if cannot get data
+*/
+#ifdef HAVE_SYSCONF__SC_NPROCESSORS_CONF 
+#define GET_NUMBER_OF_CPUS() sysconf(_SC_NPROCESSORS_CONF)
+#else
+#define GET_NUMBER_OF_CPUS() -1
+#endif
+
 #ifdef TIME_WITH_SYS_TIME
 # include <sys/time.h>
 # include <time.h>
 #include <signal.h>
 #endif
 
+/* GNU Libraries */
 #include <getopt.h>
-#include <ctype.h>
-
-#ifdef HAVE_LWRES_NETDB_H
-#include <lwres/netdb.h>
-#else
-# if !HAVE_GETADDRINFO
-#  include "getaddrinfo.h"
-# else
-#  include <netdb.h>
-# endif
-#endif
+#include "dirname.h"
+#include "vasprintf.h"
+#include "snprintf.h"
+#include "vsnprintf.h"
 
 #ifdef HAVE_LOCALE_H
 #include <locale.h>
 # define strtoul(a,b,c) (unsigned long)atol((a))
 #endif
 
-#ifndef HAVE_ASPRINTF
-int asprintf(char **strp, const char *fmt, ...);
-#endif
-
-#ifndef HAVE_VASPRINTF
-/* int vasprintf(char **strp, const char *fmt, va_list ap); */
-#endif
-
-#ifndef HAVE_SNPRINTF
-int snprintf(char *str, size_t size, const  char  *format, ...);
-#endif
-
-#ifndef HAVE_VSNPRINTF
-int vsnprintf(char *str, size_t size, const char  *format, va_list ap);
-#endif
-
 /* SSL implementations */
 #ifdef HAVE_GNUTLS_OPENSSL_H
 #  include <gnutls/openssl.h>
@@ -211,7 +201,7 @@ enum {
 
 enum {
        DEFAULT_SOCKET_TIMEOUT = 10,     /* timeout after 10 seconds */
-       MAX_INPUT_BUFFER = 1024,             /* max size of most buffers we use */
+       MAX_INPUT_BUFFER = 8192,             /* max size of most buffers we use */
        MAX_HOST_ADDRESS_LENGTH = 256    /* max size of a host address */
 };