Index: /trunk/include/samhain.h
===================================================================
--- /trunk/include/samhain.h	(revision 19)
+++ /trunk/include/samhain.h	(revision 20)
@@ -252,4 +252,7 @@
 extern long int eintr__result;
 
+extern int     sh_argc_store;
+extern char ** sh_argv_store;
+
 #include "sh_calls.h"
 
Index: /trunk/include/sh_calls.h
===================================================================
--- /trunk/include/sh_calls.h	(revision 19)
+++ /trunk/include/sh_calls.h	(revision 20)
@@ -53,5 +53,5 @@
 			 struct sigaction *oldact);
 
-int      sh_calls_set_bind_addr (char *);
+int      sh_calls_set_bind_addr (const char *);
 long int retry_connect(char * file, int line,
 		       int fd, struct sockaddr *serv_addr, int addrlen);
Index: /trunk/include/sh_error.h
===================================================================
--- /trunk/include/sh_error.h	(revision 19)
+++ /trunk/include/sh_error.h	(revision 20)
@@ -91,7 +91,7 @@
 
 
-int sh_error_verify (char * s);
-int sh_error_logverify_mod (char * s); /* just list, don't verify */
-int sh_error_logverify (char * s);
+int sh_error_verify (const char * s);
+int sh_error_logverify_mod (const char * s); /* just list, don't verify */
+int sh_error_logverify (const char * s);
 
 void sh_error_dbg_switch(void);
@@ -124,5 +124,5 @@
 /* set level for error logging 
  */
-int sh_error_setlog(char * str_s);
+int sh_error_setlog(const char * str_s);
 
 /* set severity levels
@@ -132,34 +132,34 @@
 /* set priorities
  */
-int sh_error_set_level(char * str_s, int *facility);
+int sh_error_set_level(const char * str_s, int *facility);
 
 /* set level for TCP export
  */
-int sh_error_setexport(char *  str_s);
+int sh_error_setexport(const char *  str_s);
 
 /* set level for syslog
  */
-int sh_error_set_syslog (char * flag_s);
+int sh_error_set_syslog (const char * flag_s);
 
 /* set level for printing
  */
-int sh_error_setprint(char *  flag_s);
+int sh_error_setprint(const char *  flag_s);
 
 /* set severity for external
  */
-int sh_error_set_external (char * str_s);
+int sh_error_set_external (const char * str_s);
 
 /* set severity for external
  */
-int sh_error_set_database (char * str_s);
+int sh_error_set_database (const char * str_s);
 
 /* set severity for external
  */
-int sh_error_set_prelude (char * str_s);
+int sh_error_set_prelude (const char * str_s);
 
 
 /* set level for mailing
  */
-int sh_error_setseverity (char * flag);
+int sh_error_setseverity (const char * flag);
 
 /* set debug level
Index: /trunk/include/sh_files.h
===================================================================
--- /trunk/include/sh_files.h	(revision 19)
+++ /trunk/include/sh_files.h	(revision 20)
@@ -59,5 +59,5 @@
 /* set maximum recursion level
  */
-int sh_files_setrecursion (char * flag_s);
+int sh_files_setrecursion (const char * flag_s);
 
 /* select a directory stack 2=Two, else One (standard)
Index: /trunk/include/sh_forward.h
===================================================================
--- /trunk/include/sh_forward.h	(revision 19)
+++ /trunk/include/sh_forward.h	(revision 20)
@@ -22,5 +22,5 @@
 
 #ifndef SH_STANDALONE
-int sh_forward_set_strip (char * str);
+int sh_forward_set_strip (const char * str);
 
 #endif
@@ -28,5 +28,5 @@
 /* generate a random password
  */
-int sh_forward_create_password (char * dummy);
+int sh_forward_create_password (const char * dummy);
 
 /* set time limit
@@ -40,5 +40,5 @@
 /* create client entry for given password
  */
-int sh_forward_make_client (char * str);
+int sh_forward_make_client (const char * str);
 
 #ifdef SH_WITH_SERVER
Index: /trunk/include/sh_hash.h
===================================================================
--- /trunk/include/sh_hash.h	(revision 19)
+++ /trunk/include/sh_hash.h	(revision 20)
@@ -38,5 +38,5 @@
 /* write database to stdout
  */
-int sh_hash_pushdata_stdout (char * str);
+int sh_hash_pushdata_stdout (const char * str);
 
 /* version string for database
@@ -46,13 +46,13 @@
 /* List database content
  */
-int sh_hash_list_db (char * db_file);
+int sh_hash_list_db (const char * db_file);
 
 /* List database content with full detail
  */
-int set_full_detail (char * c);
+int set_full_detail (const char * c);
 
 /* List database content with full detail, comma delimited
  */
-int set_list_delimited (char * c);
+int set_list_delimited (const char * c);
 
 /* Read the database from disk.
Index: /trunk/include/sh_mail.h
===================================================================
--- /trunk/include/sh_mail.h	(revision 19)
+++ /trunk/include/sh_mail.h	(revision 20)
@@ -38,5 +38,5 @@
 /* test mailbox
  */
-int sh_mail_sigverify (char * s);
+int sh_mail_sigverify (const char * s);
 
 /* maximum number of mail attempts
Index: /trunk/include/sh_tiger.h
===================================================================
--- /trunk/include/sh_tiger.h	(revision 19)
+++ /trunk/include/sh_tiger.h	(revision 20)
@@ -17,5 +17,5 @@
 /* the checksum function
  */
-/*@owned@*/ char * sh_tiger_hash (char * filename, TigerType what, 
+/*@owned@*/ char * sh_tiger_hash (const char * filename, TigerType what, 
 				  UINT64 Length);
 
@@ -37,5 +37,5 @@
 /* GnuPG-like format
  */
-/*@owned@*/ char * sh_tiger_hash_gpg (char * filename, TigerType what, 
+/*@owned@*/ char * sh_tiger_hash_gpg (const char * filename, TigerType what, 
 				      UINT64 Length);
 #endif
Index: /trunk/include/sh_unix.h
===================================================================
--- /trunk/include/sh_unix.h	(revision 19)
+++ /trunk/include/sh_unix.h	(revision 20)
@@ -144,5 +144,5 @@
 /* chroot directory
  */
-int sh_unix_set_chroot(char * str);
+int sh_unix_set_chroot(const char * str);
 
 /* whether to use localtime for file timesatams in logs
@@ -233,6 +233,6 @@
 /* deamon mode 
  */
-int sh_unix_setdeamon  (char * dummy);
-int sh_unix_setnodeamon(char * dummy);
+int sh_unix_setdeamon  (const char * dummy);
+int sh_unix_setnodeamon(const char * dummy);
 
 /* Test whether file exists
Index: /trunk/include/sh_utils.h
===================================================================
--- /trunk/include/sh_utils.h	(revision 19)
+++ /trunk/include/sh_utils.h	(revision 20)
@@ -74,10 +74,10 @@
 /* eval boolean input
  */
-int sh_util_flagval(char * c, int * fval);
+int sh_util_flagval(const char * c, int * fval);
 
 /* ask if a file should be updated (returns S_TRUE/S_FALSE)
  */
 int sh_util_ask_update(char * path);
-int sh_util_set_interactive(char * str);
+int sh_util_set_interactive(const char * str);
 
 /* don't log output files
@@ -95,9 +95,9 @@
 /* change verifier 
  */
-int sh_util_set_newkey (char * str);
+int sh_util_set_newkey (const char * str);
 
 /* server mode 
  */
-int sh_util_setserver (char * dummy);
+int sh_util_setserver (const char * dummy);
 
 /* a simple compressor
@@ -116,9 +116,9 @@
 /* set timer for main loop
  */
-int sh_util_setlooptime (char * str);
+int sh_util_setlooptime (const char * str);
 
 /* whether init or check the database
  */
-int  sh_util_setchecksum (char * str);
+int  sh_util_setchecksum (const char * str);
 
 /* compare an in_string against a regular expression regex_str
Index: /trunk/include/slib.h
===================================================================
--- /trunk/include/slib.h	(revision 19)
+++ /trunk/include/slib.h	(revision 20)
@@ -297,29 +297,29 @@
   /* Open for writing.
    */
-  SL_TICKET  sl_open_write       (char * fname, int priviledge_mode);
+  SL_TICKET  sl_open_write       (const char * fname, int priviledge_mode);
 
   /* Open for reading.
    */
-  SL_TICKET  sl_open_read        (char * fname, int priviledge_mode);
+  SL_TICKET  sl_open_read        (const char * fname, int priviledge_mode);
 
   /* Open for reading w/minimum checking.
    */
-  SL_TICKET  sl_open_fastread    (char * fname, int priviledge_mode);
+  SL_TICKET  sl_open_fastread    (const char * fname, int priviledge_mode);
 
   /* Open for read and write.
    */
-  SL_TICKET  sl_open_rdwr        (char * fname, int priviledge_mode);
+  SL_TICKET  sl_open_rdwr        (const char * fname, int priviledge_mode);
 
   /* Open for read and write, fail if file exists.
    */
-  SL_TICKET sl_open_safe_rdwr    (char * fname, int priv);
+  SL_TICKET sl_open_safe_rdwr    (const char * fname, int priv);
 
   /* Open for write, truncate.
    */
-  SL_TICKET  sl_open_write_trunc (char * fname, int priviledge_mode);
+  SL_TICKET  sl_open_write_trunc (const char * fname, int priviledge_mode);
 
   /* Open for read and write, truncate.
    */
-  SL_TICKET  sl_open_rdwr_trunc  (char * fname, int priviledge_mode);
+  SL_TICKET  sl_open_rdwr_trunc  (const char * fname, int priviledge_mode);
 
   /* Close file.
@@ -394,4 +394,10 @@
   char * sl_trust_errfile(void);
 
+  /* Overflow tests
+   */
+  int sl_ok_muli (int a, int b);
+  int sl_ok_divi (int a, int b);
+  int sl_ok_addi (int a, int b);
+  int sl_ok_subi (int a, int b);
 
 #ifdef  __cplusplus
@@ -500,6 +506,6 @@
 void sl_trace_in   (char * str, char * file, int line);
 void sl_trace_out  (char * str, char * file, int line);
-int  sl_trace_file (char * str);
-int  sl_trace_use  (char * str);
+int  sl_trace_file (const char * str);
+int  sl_trace_use  (const char * str);
 
 
Index: /trunk/src/samhain.c
===================================================================
--- /trunk/src/samhain.c	(revision 19)
+++ /trunk/src/samhain.c	(revision 20)
@@ -1262,4 +1262,6 @@
 
 #if !defined(SH_STEALTH_NOCL)
+  sh_argc_store = argc;
+  sh_argv_store = argv;
   (void) sh_getopt_get (argc, argv);
 #else
@@ -1283,4 +1285,8 @@
 	    }
 	  } while (my_argc < 32);
+
+	  sh_argc_store = my_argc;
+	  sh_argv_store = my_argv;
+
 	  (void) sh_getopt_get (my_argc, my_argv);
 	  SH_FREE (command_line);
Index: /trunk/src/sh_calls.c
===================================================================
--- /trunk/src/sh_calls.c	(revision 19)
+++ /trunk/src/sh_calls.c	(revision 20)
@@ -136,5 +136,5 @@
 static int        use_bind_addr = 0;
 
-int sh_calls_set_bind_addr (char * str)
+int sh_calls_set_bind_addr (const char * str)
 {
   static int reject = 0;
Index: /trunk/src/sh_err_log.c
===================================================================
--- /trunk/src/sh_err_log.c	(revision 19)
+++ /trunk/src/sh_err_log.c	(revision 20)
@@ -116,5 +116,5 @@
 static int just_list = S_FALSE;
 
-int sh_error_logverify_mod (char * s)
+int sh_error_logverify_mod (const char * s)
 {
   just_list = S_TRUE;
@@ -125,5 +125,5 @@
 } 
 
-int sh_error_logverify (char * s)
+int sh_error_logverify (const char * s)
 {
   SL_TICKET fd;
Index: /trunk/src/sh_error.c
===================================================================
--- /trunk/src/sh_error.c	(revision 19)
+++ /trunk/src/sh_error.c	(revision 20)
@@ -115,5 +115,5 @@
  *********************************************/
 
-int sh_error_verify (char * s)
+int sh_error_verify (const char * s)
 {
   char * foo;
@@ -504,10 +504,10 @@
 }
 
-int sh_error_set_level(char * str_in, int * facility)
+int sh_error_set_level(const char * str_in, int * facility)
 {
   register int  i, j, f = BAD;
 
   int  old_facility;
-  char * str_s = str_in;
+  const char * str_s = str_in;
 
   SL_ENTER(_("sh_error_set_level"));
@@ -636,5 +636,5 @@
 /* set severity for TCP export
  */
-int sh_error_setexport(char *  str_s)
+int sh_error_setexport(const char *  str_s)
 {
   static int reject = 0;
@@ -653,5 +653,5 @@
 extern void dlog_set_active(int flag);
 
-int sh_error_setprint(char *  str_s)
+int sh_error_setprint(const char *  str_s)
 {
   static int reject = 0;
@@ -676,5 +676,5 @@
 /* set level for error logging
  */
-int sh_error_setlog(char * str_s)
+int sh_error_setlog(const char * str_s)
 {
   static int reject = 0;
@@ -691,5 +691,5 @@
 /* set severity for syslog
  */
-int sh_error_set_syslog (char * str_s)
+int sh_error_set_syslog (const char * str_s)
 {
   static int reject = 0;
@@ -706,5 +706,5 @@
 /* set severity for external
  */
-int sh_error_set_external (char * str_s)
+int sh_error_set_external (const char * str_s)
 {
   static int reject = 0;
@@ -722,5 +722,5 @@
 /* set severity for database
  */
-int sh_error_set_database (char * str_s)
+int sh_error_set_database (const char * str_s)
 {
   static int reject = 0;
@@ -738,5 +738,5 @@
 /* set severity for prelude
  */
-int sh_error_set_prelude (char * str_s)
+int sh_error_set_prelude (const char * str_s)
 {
   static int reject = 0;
@@ -784,5 +784,5 @@
 /* set severity for mailing
  */
-int sh_error_setseverity (char * str_s)
+int sh_error_setseverity (const char * str_s)
 {
   static int reject = 0;
Index: /trunk/src/sh_files.c
===================================================================
--- /trunk/src/sh_files.c	(revision 19)
+++ /trunk/src/sh_files.c	(revision 20)
@@ -168,5 +168,5 @@
 /* set default recursion level
  */
-int sh_files_setrecursion (char * flag_s)
+int sh_files_setrecursion (const char * flag_s)
 {
   long flag = 0;
Index: /trunk/src/sh_forward.c
===================================================================
--- /trunk/src/sh_forward.c	(revision 19)
+++ /trunk/src/sh_forward.c	(revision 20)
@@ -202,5 +202,5 @@
 static int StripDomain = S_TRUE;
 
-int sh_forward_set_strip (char * str)
+int sh_forward_set_strip (const char * str)
 {
   static int fromcl = 0;
@@ -1720,5 +1720,5 @@
 #ifndef USE_SRP_PROTOCOL
 
-int sh_forward_make_client (char * str)
+int sh_forward_make_client (const char * str)
 {
   /* char *          safer; */
@@ -1767,5 +1767,5 @@
 #else
 
-int sh_forward_make_client (char * str)
+int sh_forward_make_client (const char * str)
 {
   char * foo_v;
@@ -1822,5 +1822,5 @@
 
 
-int sh_forward_create_password (char * dummy)
+int sh_forward_create_password (const char * dummy)
 {
   UINT32   val[2]; 
Index: /trunk/src/sh_getopt.c
===================================================================
--- /trunk/src/sh_getopt.c	(revision 19)
+++ /trunk/src/sh_getopt.c	(revision 20)
@@ -40,5 +40,5 @@
 #endif
 
-extern int      sh_calls_set_bind_addr (char *);
+extern int      sh_calls_set_bind_addr (const char *);
 
 #undef  FIL__
@@ -56,13 +56,13 @@
   char * usage;
   int          hasArg;
-  int (*func)(char * opt);
+  int (*func)(const char * opt);
 } opttable_t;
 
 /*@noreturn@*/
-static int sh_getopt_usage (char * dummy);
+static int sh_getopt_usage (const char * dummy);
 #if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE) 
-static int sh_getopt_forever (char * dummy);
-#endif
-static int sh_getopt_copyright (char * dummy);
+static int sh_getopt_forever (const char * dummy);
+#endif
+static int sh_getopt_copyright (const char * dummy);
 
 static opttable_t op_table[] = {
@@ -258,4 +258,32 @@
     HAS_ARG_NO, 
     sh_getopt_usage },
+#if defined(HAVE_LIBPRELUDE) && defined(HAVE_LIBPRELUDE_9)
+  /* need to skip over these */
+  { N_("prelude"),  
+    '-', 
+    N_("Prelude generic options"),  
+    HAS_ARG_NO, 
+    NULL },
+  { N_("profile"),  
+    '-', 
+    N_("Profile to use for this analyzer"),  
+    HAS_ARG_YES, 
+    NULL },
+  { N_("heartbeat-interval"),  
+    '-', 
+    N_("Number of seconds between two heartbeats"),  
+    HAS_ARG_YES, 
+    NULL },
+  { N_("server-addr"),  
+    '-', 
+    N_("Address where this sensor should report to"),  
+    HAS_ARG_YES, 
+    NULL },
+  { N_("analyzer-name"),  
+    '-', 
+    N_("Name for this analyzer"),  
+    HAS_ARG_YES, 
+    NULL },
+#endif
   /* last entry -- required !! -- */
   { NULL, 
@@ -266,5 +294,5 @@
 };
 
-static int sh_getopt_copyright (char * dummy)
+static int sh_getopt_copyright (const char * dummy)
 {
   fprintf (stdout, 
@@ -331,5 +359,5 @@
 
 /*@noreturn@*/
-static int sh_getopt_usage (char * dummy)
+static int sh_getopt_usage (const char * dummy)
 {
   int  i;
@@ -413,5 +441,5 @@
 
 #if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE) 
-static int sh_getopt_forever (char * dummy)
+static int sh_getopt_forever (const char * dummy)
 {
   dummy = (void *) dummy;
@@ -489,5 +517,6 @@
 			      /* call function with argument */
 			      --argc; ++argv;
-			      if (0 != (* op_table[i].func )(argv[1]))
+			      if (NULL != op_table[i].func &&
+				  0 != (* op_table[i].func )(argv[1]))
 				fprintf (stderr, 
 					 _("Error processing option -%c"),
@@ -498,5 +527,6 @@
 		      else 
 			{
-			  if (0 != (* op_table[i].func )(NULL))
+			  if (NULL != op_table[i].func &&
+			      0 != (* op_table[i].func )(NULL))
 			    fprintf (stderr, 
 				     _("Error processing option -%c"),
@@ -540,7 +570,22 @@
 		      if ( (theequal = strchr(argv[1], '=')) == NULL) 
 			{ 
-			  fprintf (stderr, _("Error: missing argument\n"));
-			  /* argument required, but no avail */
-			  (void) sh_getopt_usage(_("fail"));
+			  if (argc < 3) 
+			    { 
+			      /* argument required, but no avail 
+			       */
+			      fprintf (stderr, _("Error: missing argument\n"));
+			      (void) sh_getopt_usage(_("fail"));
+			    } 
+			  else 
+			    {
+			      /* call function with argument */
+			      --argc; ++argv;
+			      if (NULL != op_table[i].func &&
+				  0 != (* op_table[i].func )(argv[1]))
+				fprintf (stderr, 
+					 _("Error processing option -%s"),
+					 op_table[i].longopt);
+			      break;
+			    }
 			} 
 		      else 
@@ -550,5 +595,6 @@
 			      ++theequal;
 			      /* call function with argument */
-			      if (0 != (* op_table[i].func )(theequal))
+			      if (NULL != op_table[i].func &&
+				  0 != (* op_table[i].func )(theequal))
 				fprintf (stderr, 
 					 _("Error processing option -%s"),
@@ -566,5 +612,6 @@
 		  else 
 		    {
-		      if (0 != (* op_table[i].func )(NULL))
+		      if (NULL != op_table[i].func && 
+			  0 != (* op_table[i].func )(NULL))
 			fprintf (stderr, 
 				 _("Error processing option -%s"),
Index: /trunk/src/sh_hash.c
===================================================================
--- /trunk/src/sh_hash.c	(revision 19)
+++ /trunk/src/sh_hash.c	(revision 20)
@@ -759,5 +759,5 @@
  *
  ******************************************************************/
-int sh_hash_setdataent (SL_TICKET fd, char * line, int size, char * file)
+int sh_hash_setdataent (SL_TICKET fd, char * line, int size, const char * file)
 {
   long i;
@@ -1261,5 +1261,5 @@
 static char * sh_db_version_string = NULL;
 
-int sh_hash_pushdata_stdout (char * str)
+int sh_hash_pushdata_stdout (const char * str)
 {
   if (!str)
@@ -3127,5 +3127,5 @@
 static int ListWithDelimiter = S_FALSE;
 
-int set_full_detail (char * c)
+int set_full_detail (const char * c)
 {
   ListFullDetail = S_TRUE;
@@ -3137,5 +3137,5 @@
 }
  
-int set_list_delimited (char * c)
+int set_list_delimited (const char * c)
 {
   ListFullDetail = S_TRUE;
@@ -3259,5 +3259,5 @@
 }
 
-int sh_hash_list_db (char * db_file)
+int sh_hash_list_db (const char * db_file)
 {
   sh_file_t * p;
Index: /trunk/src/sh_mail.c
===================================================================
--- /trunk/src/sh_mail.c	(revision 19)
+++ /trunk/src/sh_mail.c	(revision 20)
@@ -93,5 +93,5 @@
 static mail_trail_type * mail_trail = NULL;
 
-int sh_mail_sigverify (char * s)
+int sh_mail_sigverify (const char * s)
 {
   SL_TICKET  fd;
Index: /trunk/src/sh_prelude.c
===================================================================
--- /trunk/src/sh_prelude.c	(revision 19)
+++ /trunk/src/sh_prelude.c	(revision 20)
@@ -55,4 +55,7 @@
 #include <pwd.h>
 #include <grp.h>
+
+int     sh_argc_store;
+char ** sh_argv_store;
 
 #if defined(HAVE_LIBPRELUDE) && defined(HAVE_LIBPRELUDE_9)
@@ -933,4 +936,8 @@
         idmef_analyzer_t *analyzer;
         prelude_client_flags_t flags;
+#ifdef SH_NOFAILOVER
+	prelude_connection_pool_t *pool;
+	prelude_connection_pool_flags_t conn_flags;
+#endif
 
 	if (ready_for_init == 0)
@@ -941,5 +948,5 @@
 
 	prelude_thread_init(NULL);
-        prelude_init(NULL, NULL);
+        prelude_init(&sh_argc_store, sh_argv_store);
 
         ret = prelude_client_new(&client, profile ? profile : _("samhain"));
@@ -968,4 +975,12 @@
         prelude_string_set_dup(str, IDMEF_ANALYZER_VERSION);
         
+#ifdef SH_NOFAILOVER
+	pool = prelude_client_get_connection_pool(client);
+	conn_flags = prelude_connection_pool_get_flags(pool);
+
+	conn_flags &= ~PRELUDE_CONNECTION_POOL_FLAGS_FAILOVER;
+	prelude_connection_pool_set_flags(pool, conn_flags);
+#endif
+
         ret = prelude_client_start(client);
         if ( ret < 0 ) {
Index: /trunk/src/sh_readconf.c
===================================================================
--- /trunk/src/sh_readconf.c	(revision 19)
+++ /trunk/src/sh_readconf.c	(revision 20)
@@ -731,4 +731,66 @@
 #endif
 
+/* Yes, this isn't very elegant ;)
+ */
+#if defined(WITH_EXTERNAL)
+int sh_error_set_external_wrap (char * str) { 
+  return sh_error_set_external ((const char *) str);
+}
+#endif
+#if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE)
+int sh_files_setrecursion_wrap (char * str) { 
+  return sh_files_setrecursion ((const char *) str);
+}
+int sh_util_setchecksum_wrap (char * str) { 
+  return sh_util_setchecksum ((const char *) str);
+}
+#endif
+int sh_util_setlooptime_wrap (char * str) { 
+  return sh_util_setlooptime ((const char *) str);
+}
+#ifdef SH_WITH_MAIL
+int sh_error_setseverity_wrap (char * str) { 
+  return sh_error_setseverity ((const char *) str);
+}
+#endif
+int sh_calls_set_bind_addr_wrap (char * str) { 
+  return sh_calls_set_bind_addr ((const char *) str);
+}
+int sh_unix_setdeamon_wrap (char * str) { 
+  return sh_unix_setdeamon ((const char *) str);
+}
+int sh_error_setprint_wrap (char * str) { 
+  return sh_error_setprint ((const char *) str);
+}
+int sh_error_setlog_wrap (char * str) { 
+  return sh_error_setlog ((const char *) str);
+}
+int sh_error_set_syslog_wrap (char * str) { 
+  return sh_error_set_syslog ((const char *) str);
+}
+#ifdef HAVE_LIBPRELUDE
+int sh_error_set_prelude_wrap (char * str) { 
+  return sh_error_set_prelude ((const char *) str);
+}
+#endif
+#ifdef SH_WITH_CLIENT
+int sh_error_setexport_wrap (char * str) { 
+  return sh_error_setexport ((const char *) str);
+}
+#endif
+#ifdef SH_WITH_SERVER
+int sh_forward_set_strip_wrap (char * str) { 
+  return sh_forward_set_strip ((const char *) str);
+}
+int sh_unix_set_chroot_wrap (char * str) { 
+  return sh_unix_set_chroot ((const char *) str);
+}
+#endif
+#if defined(WITH_DATABASE)
+int sh_error_set_database_wrap (char * str) { 
+  return sh_error_set_database ((const char *) str);
+}
+#endif
+ 
 cfg_options ext_table[] = {
 #if defined(WITH_EXTERNAL)
@@ -756,5 +818,5 @@
     sh_ext_add_or },
   { N_("externalseverity"),SH_SECTION_LOG,      SH_SECTION_EXTERNAL,  
-    sh_error_set_external },
+    sh_error_set_external_wrap },
   { N_("externalclass"),   SH_SECTION_LOG,      SH_SECTION_EXTERNAL,  
     sh_error_external_mask },
@@ -840,7 +902,7 @@
     sh_util_obscure_ok },
   { N_("setrecursionlevel"),  SH_SECTION_MISC,   SH_SECTION_NONE, 
-    sh_files_setrecursion },
+    sh_files_setrecursion_wrap },
   { N_("checksumtest"),       SH_SECTION_MISC,   SH_SECTION_NONE, 
-    sh_util_setchecksum },
+    sh_util_setchecksum_wrap },
   { N_("reportonlyonce"),     SH_SECTION_MISC,   SH_SECTION_NONE, 
     sh_files_reportonce },
@@ -915,9 +977,9 @@
     sh_socket_password },
   { N_("setstripdomain"),      SH_SECTION_SRV,  SH_SECTION_MISC, 
-    sh_forward_set_strip },
+    sh_forward_set_strip_wrap },
   { N_("useseparatelogs"),     SH_SECTION_SRV,  SH_SECTION_MISC, 
     set_flag_sep_log },
   { N_("setchrootdir"),        SH_SECTION_SRV,  SH_SECTION_MISC, 
-    sh_unix_set_chroot },
+    sh_unix_set_chroot_wrap },
   { N_("setclienttimelimit"),  SH_SECTION_SRV,  SH_SECTION_MISC, 
     sh_forward_set_time_limit },
@@ -940,5 +1002,5 @@
 #ifdef SH_WITH_CLIENT
   { N_("exportseverity"),      SH_SECTION_LOG,  SH_SECTION_NONE, 
-    sh_error_setexport },
+    sh_error_setexport_wrap },
   { N_("exportclass"),         SH_SECTION_LOG,  SH_SECTION_NONE, 
     sh_error_export_mask },
@@ -949,9 +1011,9 @@
     sh_readconf_setFiletime },
   { N_("setlooptime"),     SH_SECTION_MISC,  SH_SECTION_NONE, 
-    sh_util_setlooptime },
+    sh_util_setlooptime_wrap },
 
 #ifdef SH_WITH_MAIL
   { N_("mailseverity"),      SH_SECTION_LOG,   SH_SECTION_NONE, 
-    sh_error_setseverity },
+    sh_error_setseverity_wrap },
   { N_("mailclass"),         SH_SECTION_LOG,   SH_SECTION_NONE, 
     sh_error_mail_mask },
@@ -978,7 +1040,7 @@
 #endif
   { N_("setbindaddress"),    SH_SECTION_MISC,  SH_SECTION_NONE,
-    sh_calls_set_bind_addr },
+    sh_calls_set_bind_addr_wrap },
   { N_("daemon"),            SH_SECTION_MISC,  SH_SECTION_NONE, 
-    sh_unix_setdeamon },
+    sh_unix_setdeamon_wrap },
   { N_("samhainpath"),       SH_SECTION_MISC,  SH_SECTION_NONE, 
     sh_unix_self_hash },
@@ -989,20 +1051,20 @@
 
   { N_("printseverity"),     SH_SECTION_LOG,   SH_SECTION_NONE, 
-    sh_error_setprint },
+    sh_error_setprint_wrap },
   { N_("printclass"),        SH_SECTION_LOG,   SH_SECTION_NONE, 
     sh_error_print_mask },
 
   { N_("logseverity"),       SH_SECTION_LOG,   SH_SECTION_NONE, 
-    sh_error_setlog },
+    sh_error_setlog_wrap },
   { N_("logclass"),          SH_SECTION_LOG,   SH_SECTION_NONE, 
     sh_error_log_mask },
 
   { N_("syslogseverity"),    SH_SECTION_LOG,   SH_SECTION_NONE, 
-    sh_error_set_syslog },
+    sh_error_set_syslog_wrap },
   { N_("syslogclass"),       SH_SECTION_LOG,   SH_SECTION_NONE, 
     sh_error_syslog_mask },
 #ifdef HAVE_LIBPRELUDE
   { N_("preludeseverity"),   SH_SECTION_LOG,   SH_SECTION_NONE, 
-    sh_error_set_prelude },
+    sh_error_set_prelude_wrap },
   { N_("preludeclass"),      SH_SECTION_LOG,   SH_SECTION_NONE, 
     sh_error_prelude_mask },
Index: /trunk/src/sh_tiger0.c
===================================================================
--- /trunk/src/sh_tiger0.c	(revision 19)
+++ /trunk/src/sh_tiger0.c	(revision 20)
@@ -103,9 +103,9 @@
 #if defined(TIGER_64_BIT)
 static
-word64 * sh_tiger_hash_val (char * filename, TigerType what, 
+word64 * sh_tiger_hash_val (const char * filename, TigerType what, 
 			    UINT64 Length, int timeout)
 #else
 static
-sh_word32 * sh_tiger_hash_val (char * filename, TigerType what, 
+sh_word32 * sh_tiger_hash_val (const char * filename, TigerType what, 
 			       UINT64 Length, int timeout)
 #endif
@@ -1418,8 +1418,8 @@
 }
 
-static char * sh_tiger_hash_internal (char * filename, TigerType what, 
+static char * sh_tiger_hash_internal (const char * filename, TigerType what, 
 				      UINT64 Length, int timeout);
 
-char * sh_tiger_hash (char * filename, TigerType what, 
+char * sh_tiger_hash (const char * filename, TigerType what, 
 		      UINT64 Length)
 {
@@ -1444,5 +1444,5 @@
  * -------   end new ---------  */
   
-static char * sh_tiger_hash_internal (char * filename, TigerType what, 
+static char * sh_tiger_hash_internal (const char * filename, TigerType what, 
 				      UINT64 Length, int timeout)
 {
@@ -1490,5 +1490,5 @@
 }
 
-char * sh_tiger_hash_gpg (char * filename, TigerType what, 
+char * sh_tiger_hash_gpg (const char * filename, TigerType what, 
 			  UINT64 Length)
 {
Index: /trunk/src/sh_unix.c
===================================================================
--- /trunk/src/sh_unix.c	(revision 19)
+++ /trunk/src/sh_unix.c	(revision 20)
@@ -1601,5 +1601,5 @@
 char * chroot_dir = NULL;
 
-int sh_unix_set_chroot(char * str)
+int sh_unix_set_chroot(const char * str)
 {
   size_t len;
@@ -1652,5 +1652,5 @@
 static int block_setdeamon = 0;
 
-int sh_unix_setdeamon(char * dummy)
+int sh_unix_setdeamon(const char * dummy)
 {
   int    res = 0;
@@ -1675,5 +1675,5 @@
 #endif
 
-int sh_unix_setnodeamon(char * dummy)
+int sh_unix_setnodeamon(const char * dummy)
 {
   int    res = 0;
Index: /trunk/src/sh_utils.c
===================================================================
--- /trunk/src/sh_utils.c	(revision 19)
+++ /trunk/src/sh_utils.c	(revision 20)
@@ -51,5 +51,5 @@
 UINT32 ErrFlag[2];
 
-int sh_util_flagval(char * c, int * fval)
+int sh_util_flagval(const char * c, int * fval)
 {
   SL_ENTER(_("sh_util_flagval"));
@@ -101,10 +101,9 @@
 static int sh_ask_update = S_FALSE;
 
-int sh_util_set_interactive(char * str)
-{
-  if (str == NULL)
-    sh_ask_update = S_TRUE;
-  else
-    sh_ask_update = S_TRUE;
+int sh_util_set_interactive(const char * str)
+{
+  (void) str;
+
+  sh_ask_update = S_TRUE;
 
   sh_unix_setnodeamon(NULL);
@@ -950,5 +949,5 @@
 static void copy_four (unsigned char * dest, UINT32 in);
 
-int sh_util_set_newkey (char * new)
+int sh_util_set_newkey (const char * new_in)
 {
   size_t i, j = 0;
@@ -964,4 +963,5 @@
   long ii, k = 0;
   UINT32    * h1;
+  char * new;
 
   if (0 != sl_is_suid())
@@ -973,5 +973,5 @@
     }
         
-  if (new == NULL || new[0] == '\0')
+  if (new_in == NULL || new_in[0] == '\0')
     {
       fprintf(stderr, 
@@ -981,4 +981,9 @@
       return -1;
     }
+
+  if (NULL == (new = malloc(strlen(new_in) + 1)))
+    goto bail_mem;
+  sl_strncpy(new, new_in, strlen(new_in) + 1);
+
   key = new;
   len = strlen(new);
@@ -1158,17 +1163,15 @@
 /* server mode 
  */
-int sh_util_setserver (char * dummy)
+int sh_util_setserver (const char * dummy)
 {
   SL_ENTER(_("sh_util_setserver"));
 
-  if (dummy)
-    sh.flag.isserver = GOOD;
-  else
-    sh.flag.isserver = GOOD;
+  (void) dummy;
+  sh.flag.isserver = GOOD;
   SL_RETURN((0),_("sh_util_setserver"));
 }
 
 
-int sh_util_setlooptime (char * str)
+int sh_util_setlooptime (const char * str)
 {
   int i = atoi (str);
@@ -1187,5 +1190,5 @@
 
 #if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE)
-int  sh_util_setchecksum (char * str)
+int  sh_util_setchecksum (const char * str)
 {
   static int reject = 0;
Index: /trunk/src/slib.c
===================================================================
--- /trunk/src/slib.c	(revision 19)
+++ /trunk/src/slib.c	(revision 20)
@@ -6,5 +6,5 @@
 #include <stdarg.h>
 #include <string.h>
-
+#include <limits.h>
 
 #include <unistd.h>
@@ -98,5 +98,5 @@
 static FILE * trace_fp     = NULL;
 
-int  sl_trace_use (char * dummy)
+int  sl_trace_use (const char * dummy)
 {
   if (dummy)
@@ -107,5 +107,5 @@
 }
 
-int  sl_trace_file (char * str)
+int  sl_trace_file (const char * str)
 {
   if (!str)
@@ -1638,5 +1638,5 @@
 
 static
-int sl_open_file (char *filename, int mode, int priv)
+int sl_open_file (const char *filename, int mode, int priv)
 {
   struct stat   lbuf;
@@ -1848,5 +1848,5 @@
 
 static
-int check_fname_priv (char * fname, int priv)
+int check_fname_priv (const char * fname, int priv)
 {
   SL_ENTER(_("check_fname_priv"));
@@ -1858,5 +1858,5 @@
 }
   
-SL_TICKET sl_open_write (char * fname, int priv)
+SL_TICKET sl_open_write (const char * fname, int priv)
 {
   long status;
@@ -1870,5 +1870,5 @@
 }
 
-SL_TICKET sl_open_read (char * fname, int priv)
+SL_TICKET sl_open_read (const char * fname, int priv)
 {
   long status;
@@ -1887,5 +1887,5 @@
 }
 
-SL_TICKET sl_open_fastread (char * fname, int priv)
+SL_TICKET sl_open_fastread (const char * fname, int priv)
 {
   long status;
@@ -1899,5 +1899,5 @@
 }
 
-SL_TICKET sl_open_rdwr (char * fname, int priv)
+SL_TICKET sl_open_rdwr (const char * fname, int priv)
 {
   long status;
@@ -1911,5 +1911,5 @@
 }
 
-SL_TICKET sl_open_safe_rdwr (char * fname, int priv)
+SL_TICKET sl_open_safe_rdwr (const char * fname, int priv)
 {
   long status;
@@ -1923,5 +1923,5 @@
 }
 
-SL_TICKET sl_open_write_trunc (char * fname, int priv)
+SL_TICKET sl_open_write_trunc (const char * fname, int priv)
 {
   long status;
@@ -1935,5 +1935,5 @@
 }
 
-SL_TICKET sl_open_rdwr_trunc (char * fname, int priv)
+SL_TICKET sl_open_rdwr_trunc (const char * fname, int priv)
 {
   long status;
@@ -2490,3 +2490,60 @@
 }
 
-
+/* ---------------------------------------------------------------- 
+ *
+ *    Overflow tests
+ *
+ * ---------------------------------------------------------------- */
+
+int sl_ok_muli (int a, int b) /* a*b */
+{
+  if (a >= (INT_MIN / b) && a <= (INT_MAX / b))
+    return SL_TRUE; /* no overflow */
+  return SL_FALSE;
+}
+
+int sl_ok_divi (int a, int b) /* a/b */
+{
+  (void) a;
+  if (b != 0)
+    return SL_TRUE; /* no overflow */
+  return SL_FALSE;
+}
+
+int sl_ok_addi (int a, int b) /* a+b */
+{
+  if (a >= 0 && b >= 0)
+    {
+      if (a <= (INT_MAX - b))
+	return SL_TRUE; /* no overflow */
+      else
+	return SL_FALSE;
+    }
+  else if (a < 0 && b < 0)
+    {
+      if (a >= (INT_MIN - b))
+	return SL_TRUE; /* no overflow */
+      else
+	return SL_FALSE;
+    }
+  return SL_TRUE;
+}
+
+int sl_ok_subi (int a, int b) /* a-b */
+{
+  if (a >= 0 && b < 0)
+    {
+      if (a <= (INT_MAX + b))
+	return SL_TRUE; /* no overflow */
+      else
+	return SL_FALSE;
+    }
+  else if (a < 0 && b >= 0)
+    {
+      if (a >= (INT_MIN + b))
+	return SL_TRUE; /* no overflow */
+      else
+	return SL_FALSE;
+    }
+  return SL_TRUE;
+}
Index: /trunk/test/testrun_1b.sh
===================================================================
--- /trunk/test/testrun_1b.sh	(revision 19)
+++ /trunk/test/testrun_1b.sh	(revision 20)
@@ -102,8 +102,10 @@
     rm -f $PW_DIR/test_log_prelude
 
-    ( "$PM" --textmod -l $PW_DIR/test_log_prelude >/dev/null 2>&1 )&
+    "$PM" --textmod -l $PW_DIR/test_log_prelude --listen 127.0.0.1:5500 >/dev/null 2>&1 &
     PID=$!
 
-    ./samhain -t check -p none -l info --set-prelude-severity=info >/dev/null
+    sleep 5
+
+    ./samhain -t check -p none -l info --set-prelude-severity=info --prelude --server-addr 127.0.0.1:5500 >/dev/null
     
     if test x$? = x0; then
@@ -166,5 +168,5 @@
 	    else
 		BUILDOPTS="--quiet $TRUST --enable-debug --with-prelude --with-gpg=${GPG} --with-checksum=no --enable-micro-stealth=137 --enable-login-watch --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$RCFILE  --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock --with-data-file=$PW_DIR/.samhain_file"
-		testrun1b_internal "${BUILDOPTS}"
+		testrun1b_internal "${BUILDOPTS} CFLAGS=-DSH_NOFAILOVER=1"
 		do_test_1b_2
 		if [ $? -eq 0 ]; then
