Index: /trunk/configure.ac
===================================================================
--- /trunk/configure.ac	(revision 382)
+++ /trunk/configure.ac	(revision 383)
@@ -12,5 +12,5 @@
 dnl start
 dnl
-AM_INIT_AUTOMAKE(samhain, 3.0.0a)
+AM_INIT_AUTOMAKE(samhain, 3.0.1)
 AC_DEFINE([SAMHAIN], 1, [Application is samhain])
 AC_CANONICAL_HOST
Index: /trunk/include/sh_mem.h
===================================================================
--- /trunk/include/sh_mem.h	(revision 382)
+++ /trunk/include/sh_mem.h	(revision 383)
@@ -35,4 +35,5 @@
 #define SH_FREE(a)   sh_mem_free((a), FIL__, __LINE__)
 #define SH_ALLOC(a)  sh_mem_malloc((a), FIL__, __LINE__) 
+#define SH_OALLOC(a,b,c)  sh_mem_malloc((a), (b), (c)) 
 
 #else
@@ -51,4 +52,7 @@
 #define SH_FREE(a)   sh_mem_free(a)
 #define SH_ALLOC(a)  sh_mem_malloc(a)
+#define SH_OALLOC(a,b,c)  ((void) (b),		 \
+			   (void) (c),		 \
+			   sh_mem_malloc(a))	 \
 
 #endif
Index: /trunk/include/sh_pthread.h
===================================================================
--- /trunk/include/sh_pthread.h	(revision 382)
+++ /trunk/include/sh_pthread.h	(revision 383)
@@ -31,5 +31,5 @@
 	do {                                                               \
                 int oldtype;                                               \
-		int executeStack = 0;                                      \
+		volatile int executeStack = 0;                             \
 		pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldtype);  \
                 pthread_cleanup_push(sh_pthread_mutex_unlock, (void*)&(M));\
Index: /trunk/src/depend-gen.c
===================================================================
--- /trunk/src/depend-gen.c	(revision 382)
+++ /trunk/src/depend-gen.c	(revision 383)
@@ -197,6 +197,8 @@
   p = strrchr(name, '/');
   if (p)
-    ++p;
-  len = strlen(p);
+    {
+      ++p;
+      len = strlen(p);
+    }
 
   /* skip other dependencies
@@ -206,5 +208,5 @@
       if (NULL == fgets(line, 1023, fout))
 	break;
-      if (0 == strncmp(line, p, len))
+      if (p && 0 == strncmp(line, p, len))
 	break;
       fprintf(ftmp, "%s", line);
Index: /trunk/src/dnmalloc.c
===================================================================
--- /trunk/src/dnmalloc.c	(revision 382)
+++ /trunk/src/dnmalloc.c	(revision 383)
@@ -2854,5 +2854,5 @@
       assert(temp != NULL);
 #endif
-      prevtemp->hash_next = temp->hash_next;
+      if (temp) prevtemp->hash_next = temp->hash_next;
     }
 }
@@ -3558,6 +3558,6 @@
     
     else {
-      front_misalign = 0;
-      end_misalign = 0;
+      /* front_misalign = 0; *//*superfluous */
+      /* end_misalign = 0; *//*superfluous */
       correction = 0;
       aligned_brk = brk;
@@ -4284,5 +4284,7 @@
   retval = sYSMALLOc(nb, av);
   if (retval) {
-    victim = mem2chunk(retval);
+#if PARANOIA > 2
+    victim = mem2chunk(retval); /* is used in guard_set macro */
+#endif
     guard_set(av->guard_stored, victim, bytes, nb);
   }
@@ -5516,5 +5518,5 @@
         } rdat;
 #if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__)
-        size_t sz = 0;
+        ssize_t sz = 0;
 	int    fd;
 #endif
@@ -5540,9 +5542,16 @@
         fd = open("/dev/urandom", O_RDONLY);
         if (fd != -1) {
-                sz = (size_t)read(fd, rdat.rnd, sizeof (rdat.rnd));
-                close(fd);
+	        sz = (size_t)read(fd, rdat.rnd, sizeof (rdat.rnd));
+		/* 
+		 * gcc complains if we ignore the return value of read(), and
+		 * the llvm/clang analyzer complains if we don't use it...
+		 */
+		if (sz > (-256)) /* always true */
+		  close(fd);
         }
+	/*
         if (sz > sizeof (rdat.rnd))
                 sz = 0;
+	*/
  #endif
 
Index: /trunk/src/rijndael-alg-fst.c
===================================================================
--- /trunk/src/rijndael-alg-fst.c	(revision 382)
+++ /trunk/src/rijndael-alg-fst.c	(revision 383)
@@ -28,5 +28,5 @@
 	 */ 
 	int j, r, t, rconpointer = 0;
-	word8 tk[MAXKC][4];
+	word8 tk[MAXKC][4] = { { 0 } }; /* init for llvm/clang analyzer */
 	int KC = ROUNDS - 6;
 	word32 tmp;
Index: /trunk/src/sh_error.c
===================================================================
--- /trunk/src/sh_error.c	(revision 382)
+++ /trunk/src/sh_error.c	(revision 383)
@@ -648,4 +648,8 @@
     }
 
+  if (!str_s)
+    {
+      SL_RETURN ((-1), _("sh_error_set_level"));
+    }
   /* skip to end of string
    */
Index: /trunk/src/sh_extern.c
===================================================================
--- /trunk/src/sh_extern.c	(revision 382)
+++ /trunk/src/sh_extern.c	(revision 383)
@@ -435,5 +435,5 @@
 		  /* failed 
 		   */
-		  _exit(EXIT_FAILURE);
+		  _exit((errnum == 0) ? (EXIT_SUCCESS) : (EXIT_FAILURE));
               }
 	      PDBGC_S("fexecve: not working");
@@ -471,5 +471,5 @@
 	  /* failed 
 	   */
-	  _exit(EXIT_FAILURE);
+	  _exit((errnum == 0) ? (EXIT_SUCCESS) : (EXIT_FAILURE));
 	}
       /* 
Index: /trunk/src/sh_files.c
===================================================================
--- /trunk/src/sh_files.c	(revision 382)
+++ /trunk/src/sh_files.c	(revision 383)
@@ -107,5 +107,5 @@
   po = SH_ALLOC(len+1); *po = '\0'; p = po; pend = &po[len];
 
-  i = 0; q = s;
+  q = s;
 
   do
@@ -925,10 +925,11 @@
 #endif
 
-int sh_files_push_file_int (int class, const char * str_s, size_t len, unsigned long check_mask)
+int sh_files_push_file_int (int class, const char * str_s, size_t len, 
+			    unsigned long check_mask)
 {
   dirstack_t * new_item_ptr;
   char  * fileName;
   int     ret;
-  int     count = 0;
+  volatile int     count = 0;
 
   SL_ENTER(_("sh_files_push_file_int"));
@@ -1022,5 +1023,5 @@
   glob_t  pglob;
 
-  int     count = 0;
+  volatile int     count = 0;
   volatile unsigned long check_mask = (flag == 0) ? sh_files_maskof(class) : check_mask_in;
   
@@ -1877,4 +1878,5 @@
 
 static void * sh_dummy_dirlist;
+static void * sh_dummy_tmpcat;
 
 /* -- Check a single directory and its content. Does not
@@ -1904,7 +1906,7 @@
   int             class  = 0;
   volatile int    rdepth_next;
-  int             class_next;
+  volatile int    class_next;
   volatile int    file_class_next;
-  unsigned long   check_mask_next;
+  volatile unsigned long   check_mask_next;
   volatile unsigned long   file_check_mask_next;
 
@@ -1921,6 +1923,4 @@
 
   SL_ENTER(_("sh_files_checkdir"));
-
-  sh_dummy_dirlist = (void *) &dirlist;
 
   if (sig_urgent > 0) {
@@ -2064,4 +2064,7 @@
   sl_strlcpy (theDir->DirPath, iname, PATH_MAX); 
 
+
+  sh_dummy_dirlist = (void *) &dirlist;
+  sh_dummy_tmpcat  = (void *) &tmpcat;
 
   /* ---- read ----
@@ -2347,4 +2350,5 @@
       {
 	SH_FREE(theDir);
+	sh_dummy_dirlist = NULL;
 	SL_RETURN((0), _("sh_files_checkdir"));
       }
@@ -2397,4 +2401,6 @@
   SH_FREE(tmpname);
   SH_FREE(theDir);
+
+  sh_dummy_dirlist = NULL;
 
   SL_RETURN((0), _("sh_files_checkdir"));
@@ -2686,5 +2692,5 @@
 			int * rdepth)
 {
-  int retval = 0;
+  volatile int retval = 0;
 #if defined(HAVE_GLOB_H) && defined(HAVE_FNMATCH_H)
   sh_globstack_t * testPattern;
@@ -2757,5 +2763,5 @@
 			 unsigned long *check_mask, int *reported)
 {
-  int retval = 0;
+  volatile int retval = 0;
 #if defined(HAVE_GLOB_H) && defined(HAVE_FNMATCH_H)
   sh_globstack_t * testPattern;
Index: /trunk/src/sh_forward.c
===================================================================
--- /trunk/src/sh_forward.c	(revision 382)
+++ /trunk/src/sh_forward.c	(revision 383)
@@ -455,5 +455,5 @@
 			    _("sh_forward_send_intern: blockEncrypt"));
 	  memcpy(q, outBlock, B_SIZ);
-	  q += B_SIZ;
+	  /* q += B_SIZ; *//* never read */
 	}
 
@@ -584,4 +584,10 @@
     }
   /*@-usedef +ignoresigns@*/
+  else if (msgbuf == NULL)
+    {
+      sh_error_handle((-1), FIL__, __LINE__, 0, MSG_E_SUBGEN,
+		      _("msgbuf is NULL"), _("sh_forward_receive_intern"));
+      SL_RETURN((-1), _("sh_forward_receive_intern"));
+    }
   else if (head[0] != protocol &&  
 	   (head[0] & SH_PROTO_SRP) == (char)0 /* not set */)
@@ -1666,5 +1672,5 @@
 	    {
 	      flag_err = (-1);
-	      sh_error_handle((-1), FIL__, __LINE__, 0, MSG_TCP_EFIL);
+	      sh_error_handle((-1), FIL__, __LINE__, flag_err, MSG_TCP_EFIL);
 	    }
 	  else
@@ -1673,5 +1679,5 @@
 	       */
 	      transfercount = 0;
-	      flag_err      = 0;
+	      /* flag_err      = 0; *//* never read */
 
 	      do {
@@ -1734,5 +1740,5 @@
 	      if (0 == check_request_nerr(head_u, _("EEOT")) &&
 		  0 <  flag_err                             &&
-		  0 == hash_check (foo_M1, answer, (int)strlen(answer)))
+		  0 == hash_check (foo_M1, answer, (int)sl_strlen(answer)))
 		{
 		  flag_err = 
@@ -1745,5 +1751,5 @@
 		  (void) sl_sync(sfd);
 		  if (flag_err_info == SL_TRUE)
-		    sh_error_handle((-1), FIL__, __LINE__, 0, MSG_TCP_FOK);
+		    sh_error_handle((-1), FIL__, __LINE__, flag_err, MSG_TCP_FOK);
 		}
 	      else
@@ -2389,4 +2395,10 @@
 				     &(conn->client_entry->keyInstE));
     }
+  else if (msg == NULL)
+    {
+      sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN,
+		      _("msg is NULL"), 
+		      _("sh_forward_prep_send_int: cipherInit"));
+    }
   else if ((S_TRUE == docrypt) && ((protocol & SH_PROTO_ENC) != 0) &&
 	   ((length2 + 1) > length2))
@@ -2431,5 +2443,5 @@
 			    _("sh_forward_prep_send_int: blockEncrypt"));
 	  memcpy(q, outBlock, B_SIZ);
-	  q += B_SIZ;
+	  /* q += B_SIZ; *//* never read */
 	}
 
@@ -2533,6 +2545,4 @@
   if (val <= 0)
     SL_RETURN( (-1), _("sh_forward_set_time_limit"));
-
-  val = (val < 0 ? 0 : val);
 
   time_client_limit = (time_t) val;
@@ -5142,5 +5152,5 @@
       conns[sock].fd    = sh_tcp_sock[sock];
       conns[sock].state = CONN_READING;
-      high_fd = (sh_tcp_sock[sock] > high_fd) ? sh_tcp_sock[sock] : high_fd;
+      /* high_fd = (sh_tcp_sock[sock] > high_fd) ? sh_tcp_sock[sock] : high_fd; */
       ++sock;
     }
@@ -5149,5 +5159,5 @@
   conns[sock].fd    = pf_unix_fd;
   conns[sock].state = CONN_READING;
-  high_fd = (pf_unix_fd > high_fd) ? pf_unix_fd : high_fd;
+  /* high_fd = (pf_unix_fd > high_fd) ? pf_unix_fd : high_fd; */
 
   sock_unix = sock;
@@ -5175,5 +5185,5 @@
 	  conns[sock].fd    = syslog_sock[s2];
 	  conns[sock].state = CONN_READING;
-	  high_fd = (high_fd > conns[sock].fd) ? high_fd : conns[sock].fd;
+	  /* high_fd = (high_fd > conns[sock].fd) ? high_fd : conns[sock].fd; */
 	  ++sock;
 	}
Index: /trunk/src/sh_gpg.c
===================================================================
--- /trunk/src/sh_gpg.c	(revision 382)
+++ /trunk/src/sh_gpg.c	(revision 383)
@@ -173,12 +173,15 @@
 
   k = 0;
-  for (i = 0; i < 127; ++i)
-    {
-      if (test_ptr2[i] == '\0')
-	break;
-      if (test_ptr2[i] != ' ')
-	{
-	  wstrip2[k] = test_ptr2[i];
-	  ++k;
+  if (test_ptr2)
+    {
+      for (i = 0; i < 127; ++i)
+	{
+	  if (test_ptr2[i] == '\0')
+	    break;
+	  if (test_ptr2[i] != ' ')
+	    {
+	      wstrip2[k] = test_ptr2[i];
+	      ++k;
+	    }
 	}
     }
@@ -552,5 +555,5 @@
       pfd = val_return;
       sl_close(checkfd);
-      checkfd = -1;
+      /* checkfd = -1; *//* never read */
 
       sl_snprintf(pname, sizeof(pname), _("/proc/self/fd/%d"), pfd);
@@ -815,5 +818,6 @@
 	{
 	  sl_strlcpy (sign_id, &line[25], SH_MINIBUF+1);
-	  sign_id[sl_strlen(sign_id)-1] = '\0';  /* remove trailing '"' */
+	  if (sign_id)
+	    sign_id[sl_strlen(sign_id)-1] = '\0';  /* remove trailing '"' */
 	  have_id = GOOD;
 	} 
@@ -839,7 +843,14 @@
 	  ptr = strchr ( line, '"');
 	  ++ptr;
-	  sl_strlcpy (sign_id, ptr, SH_MINIBUF+1);
-	  sign_id[sl_strlen(sign_id)-1] = '\0'; /* remove trailing dot */
-	  sign_id[sl_strlen(sign_id)-2] = '\0'; /* remove trailing '"' */
+	  if (ptr)
+	    {
+	      sl_strlcpy (sign_id, ptr, SH_MINIBUF+1);
+	      sign_id[sl_strlen(sign_id)-1] = '\0'; /* remove trailing dot */
+	      sign_id[sl_strlen(sign_id)-2] = '\0'; /* remove trailing '"' */
+	    }
+	  else
+	    {
+	      sl_strlcpy (sign_id, _("(null)"), SH_MINIBUF+1);
+	    }
 	  have_id = GOOD;
 	}
Index: /trunk/src/sh_hash.c
===================================================================
--- /trunk/src/sh_hash.c	(revision 382)
+++ /trunk/src/sh_hash.c	(revision 383)
@@ -600,5 +600,5 @@
 		prev->next = p->next;
 
-	      p = delete_db_entry(p);
+	      delete_db_entry(p);
 
 	      SL_RET0(_("hash_unvisited"));
@@ -693,5 +693,5 @@
 	    entries.prev->next = p->next;
 	  
-	  p = delete_db_entry(p);
+	  delete_db_entry(p);
 	  
 	  goto end;
@@ -915,12 +915,14 @@
 	      SL_RET0(_("hashinsert"));
 	    }
-	  else 
-	    if (p->next == NULL) 
-	      {
-		p->next = s;
-		p->next->next = NULL;
-		SL_RET0(_("hashinsert"));
-	      }
-	  p = p->next;
+	  else if (p && p->next == NULL) 
+	    {
+	      p->next = s;
+	      p->next->next = NULL;
+	      SL_RET0(_("hashinsert"));
+	    }
+	  if (p)
+	    p = p->next;
+	  else /* cannot really happen, but llvm/clang does not know */
+	    break;
 	}
     }
@@ -1470,5 +1472,5 @@
   sl_close (fd);
   sh_hash_getline_end();
-  fd = -1;
+  /* fd = -1; */
 
  unlock_and_return:
Index: /trunk/src/sh_html.c
===================================================================
--- /trunk/src/sh_html.c	(revision 382)
+++ /trunk/src/sh_html.c	(revision 383)
@@ -158,5 +158,5 @@
 #endif
 	  if (time_ptr != NULL) 
-	    status = strftime (ts1, 80, _("%d-%m-%Y %H:%M:%S"), time_ptr);
+	    strftime (ts1, 80, _("%d-%m-%Y %H:%M:%S"), time_ptr);
 	  now = time(NULL);
 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_LOCALTIME_R)
@@ -166,5 +166,5 @@
 #endif
 	  if (time_ptr != NULL) 
-	    status = strftime (ts2, 80, _("%d-%m-%Y %H:%M:%S"), time_ptr);
+	    strftime (ts2, 80, _("%d-%m-%Y %H:%M:%S"), time_ptr);
 
 	  sl_snprintf(outline, 1023, 
@@ -192,5 +192,5 @@
 #endif
 	      if (time_ptr != NULL) 
-		status = strftime (ts1, 80, _("%d-%m-%Y %H:%M:%S"), time_ptr);
+		strftime (ts1, 80, _("%d-%m-%Y %H:%M:%S"), time_ptr);
 	      sl_snprintf(outline, 1023, 
 			  _("<p>Last connection at %s</p>"), 
@@ -323,5 +323,5 @@
 	    {
 	      entry_size = 0;
-	      add_size   = 0;
+	      /* add_size   = 0; *//* never read */
 	      SL_RETURN( 0, _("sh_html_get_entry"));
 	    }
Index: /trunk/src/sh_inotify.c
===================================================================
--- /trunk/src/sh_inotify.c	(revision 382)
+++ /trunk/src/sh_inotify.c	(revision 383)
@@ -388,4 +388,5 @@
   SH_MUTEX_UNLOCK(mutex_list_dormant);
 
+  sh_dummy_popret = NULL;
   return popret;
 }
Index: /trunk/src/sh_log_evalrule.c
===================================================================
--- /trunk/src/sh_log_evalrule.c	(revision 382)
+++ /trunk/src/sh_log_evalrule.c	(revision 383)
@@ -635,5 +635,5 @@
   if (pflag == 'K')
     {
-      nr->label   = sh_string_new_from_lchar(dstr, strlen(dstr));
+      nr->label   = sh_string_new_from_lchar(dstr, sl_strlen(dstr));
       nr->flags  |= RFL_KEEP;
       nr->delay   = dsec;
@@ -642,5 +642,5 @@
   else if (pflag == 'M')
     {
-      nr->label   = sh_string_new_from_lchar(dstr, strlen(dstr));
+      nr->label   = sh_string_new_from_lchar(dstr, sl_strlen(dstr));
       nr->flags  |= RFL_MARK;
       nr->delay   = dsec;
@@ -919,4 +919,5 @@
     DEBUG("debug: no match found\n");
   /* If there was no match, this is NULL */
+  dummy1 = NULL;
   return rule;
 }
@@ -993,4 +994,7 @@
       } while (group);
     }
+
+  dummy2 = NULL;
+  dummy3 = NULL;
   return result;
 }
Index: /trunk/src/sh_login_track.c
===================================================================
--- /trunk/src/sh_login_track.c	(revision 382)
+++ /trunk/src/sh_login_track.c	(revision 383)
@@ -298,5 +298,6 @@
 	  while (entry)
 	    {
-	      n = fwrite(&(entry->data), sizeof(struct sh_track_entry_data), 1, fp);
+	      fwrite(&(entry->data), sizeof(struct sh_track_entry_data), 
+		     1, fp);
 	      entry = entry->next;
 	    }
@@ -426,7 +427,7 @@
     }
 
-  while (*p && (*p == ' ' || *p == '\t')) ++p;
-
-  if (*p && (i < SH_LTRACK_USIZE) && (*p == ':'))
+  while (p && *p && (*p == ' ' || *p == '\t')) ++p;
+
+  if (p && *p && (i < SH_LTRACK_USIZE) && (*p == ':'))
     {
       user[i] = '\0';
@@ -970,7 +971,4 @@
 
   urecord    = load_data(user);
-  last_login = (urecord->head).last_login;
-
-  urecord = load_data(user);
   last_login = (urecord->head).last_login;
 
Index: /trunk/src/sh_mail.c
===================================================================
--- /trunk/src/sh_mail.c	(revision 382)
+++ /trunk/src/sh_mail.c	(revision 383)
@@ -458,6 +458,6 @@
 }
 
-void sh_mail_signature_block (sh_string  * sigMsg, char * recipient,
-			      char * bufcompress)
+sh_string * sh_mail_signature_block (sh_string  * sigMsg, char * recipient,
+				     char * bufcompress)
 {
   time_t         id_audit;
@@ -511,5 +511,5 @@
     sigMsg     = sh_string_add_from_char(sigMsg, _("-----END MESSAGE-----"));
 
-    return;
+    return sigMsg;
 }
 
@@ -599,5 +599,9 @@
      * how to filter messages. */
 
-    theMsg = sh_string_new_from_lchar(message, strlen(message));
+    theMsg = sh_string_new_from_lchar(message, sl_strlen(message));
+    if (!theMsg)
+      {
+	SL_RETURN((-1), _("sh_mail_msg"));
+      }
 
     /* ---------- Header  ---------------------------------------- */
@@ -694,7 +698,7 @@
 			sh_string  * sigMsg  = sh_string_new (0);
 
-			sh_mail_signature_block (sigMsg, 
-						 sh_string_str(address_list->recipient),
-						 bufcompress);
+			sigMsg = sh_mail_signature_block (sigMsg, 
+							  sh_string_str(address_list->recipient),
+							  bufcompress);
 
 			wrlen = fwrite (sh_string_str(sigMsg), 1, 
@@ -746,7 +750,7 @@
 		sh_string  * sigMsg  = sh_string_new (0);
 		
-		sh_mail_signature_block (sigMsg, 
-					 NULL,
-					 bufcompress);
+		sigMsg  = sh_mail_signature_block (sigMsg, 
+						   NULL,
+						   bufcompress);
 		
 		wrlen = fwrite (sh_string_str(sigMsg), 1, 
@@ -774,6 +778,8 @@
 	      }
 
-	    sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_SRV_FAIL,
-			     _("mail"), sh_string_str(ma_address->recipient));
+	    if (ma_address)
+	      sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_SRV_FAIL,
+			       _("mail"), 
+			       sh_string_str(ma_address->recipient));
 	    errcount = address_num;
 	    ++sh.statistics.mail_failed;
@@ -1652,5 +1658,5 @@
     }
 
-  ret = 0;
+
   header  = (HEADER *) reply;
 
@@ -1753,5 +1759,5 @@
       /* CLASS (re-use 'type' var)
        */
-      type = get_short (comp_dn);
+      /* type = get_short (comp_dn); *//* don't care */
       comp_dn += 2;
       if (comp_dn >= eom)
Index: /trunk/src/sh_portcheck.c
===================================================================
--- /trunk/src/sh_portcheck.c	(revision 382)
+++ /trunk/src/sh_portcheck.c	(revision 383)
@@ -605,4 +605,8 @@
       ptr = ptr->next;
     }
+
+  sh_dummy_ptr = NULL;
+  sh_dummy_pre = NULL;
+
   return;
 }
@@ -1546,4 +1550,5 @@
   } while (*str);
 
+  sh_dummy_str = NULL;
   return 0;
 }
@@ -1653,5 +1658,5 @@
 	{
 	  if (portchk_debug)
-	    fprintf(stderr, _("add_required_port\n"));
+	    fprintf(stderr, _("add_required_port %d\n"), (int) port);
 	  sh_portchk_add_to_list (proto,   -1, &saddr,  buf, type, SH_PORT_UNKN);
 	}
Index: /trunk/src/sh_processcheck.c
===================================================================
--- /trunk/src/sh_processcheck.c	(revision 382)
+++ /trunk/src/sh_processcheck.c	(revision 383)
@@ -460,4 +460,7 @@
       list = list->next;
     }
+
+  sh_dummy_watchlist = NULL;
+  return;
 }
 
@@ -518,5 +521,5 @@
   SL_ENTER(_("sh_prochk_set_pspath"));
 
-  if (!str && ('/' != str[0]))
+  if (!str || ('/' != str[0]))
     SL_RETURN((-1), _("sh_prochk_set_pspath"));
   if (sh_prochk_pspath)
Index: /trunk/src/sh_readconf.c
===================================================================
--- /trunk/src/sh_readconf.c	(revision 382)
+++ /trunk/src/sh_readconf.c	(revision 383)
@@ -142,5 +142,5 @@
   while (tmp && isspace((int)*tmp)) ++tmp;
   
-  if (tmp[0] == '$' && tmp[1] == '(')
+  if (tmp && tmp[0] == '$' && tmp[1] == '(')
     {
       size_t len = strlen(tmp);
Index: /trunk/src/sh_restrict.c
===================================================================
--- /trunk/src/sh_restrict.c	(revision 382)
+++ /trunk/src/sh_restrict.c	(revision 383)
@@ -107,12 +107,15 @@
   SL_ENTER(_("matches_prefix"));
 
-  path_len = sl_strlen(path);
-  pref_len = sl_strlen(prefix);
-  
-  if (path_len >= pref_len)
-    {
-      if (0 == strncmp(path, prefix, pref_len))
-	{
-	  SL_RETURN(1, _("matches_prefix"));
+  if (path && prefix)
+    {
+      path_len = sl_strlen(path);
+      pref_len = sl_strlen(prefix);
+      
+      if (path_len >= pref_len)
+	{
+	  if (0 == strncmp(path, prefix, pref_len))
+	    {
+	      SL_RETURN(1, _("matches_prefix"));
+	    }
 	}
     }
Index: /trunk/src/sh_socket.c
===================================================================
--- /trunk/src/sh_socket.c	(revision 382)
+++ /trunk/src/sh_socket.c	(revision 383)
@@ -997,5 +997,5 @@
 		   (struct sockaddr *) & name, size);
   */
-  nbytes = send (talkfd, _("END"), 4, 0);
+  /* nbytes = *//* never read */ send (talkfd, _("END"), 4, 0);
   sl_close_fd(FIL__, __LINE__, talkfd);
   return 0;
Index: /trunk/src/sh_string.c
===================================================================
--- /trunk/src/sh_string.c	(revision 382)
+++ /trunk/src/sh_string.c	(revision 383)
@@ -47,6 +47,4 @@
       if (*s) 
         {
-          a = s;
-
           /* move a to next delim
            */
@@ -257,9 +255,10 @@
   char * s = line;
   char * p;
+  unsigned int sind = (prefix) ? strlen(prefix) : 0;
 
   while ( *s && isspace((int)*s) ) ++s;
   if (prefix && 0 != strncmp(s, prefix, strlen(prefix)))
     return NULL;
-  s = &s[strlen(prefix)];
+  s = &s[sind];
   while ( *s && isspace((int)*s) ) ++s;
   if (!s || (*s != '('))
@@ -437,5 +436,8 @@
   s      = SH_ALLOC(sizeof(sh_string));
   s->str = SH_ALLOC(len+1);
-  memcpy(s->str, str, len);
+  if (str)
+    memcpy(s->str, str, len);
+  else
+    s->str[0] = '\0';
   s->str[len] = '\0';
   s->siz = len+1;
@@ -599,5 +601,4 @@
 
   curr = -1;
-  last = -1;
 
   for (i = 0; i < ovecnum; ++i)
Index: /trunk/src/sh_suidchk.c
===================================================================
--- /trunk/src/sh_suidchk.c	(revision 382)
+++ /trunk/src/sh_suidchk.c	(revision 383)
@@ -927,5 +927,4 @@
 	  SH_FREE(tmp);
 	  SH_FREE(msg);
-	  cperm_status = -1;
 	}
     }
@@ -1539,5 +1538,5 @@
   ShSuidchkExclude = sh_util_strdup (c);
   ExcludeLen       = sl_strlen (ShSuidchkExclude);
-  if (ShSuidchkExclude[ExcludeLen-1] == '/')
+  if (ShSuidchkExclude && ShSuidchkExclude[ExcludeLen-1] == '/')
     {
       ShSuidchkExclude[ExcludeLen-1] = '\0';
Index: /trunk/src/sh_tiger0.c
===================================================================
--- /trunk/src/sh_tiger0.c	(revision 382)
+++ /trunk/src/sh_tiger0.c	(revision 383)
@@ -287,5 +287,5 @@
 	sh.statistics.bytes_hashed += tt;
 	
-	bptr = buffer; tt = 0;
+	tt = 0;
 	for (i = 0; i < blk; ++i)
 	  {
@@ -366,5 +366,8 @@
 	/* MAY_LOCK */
 	sh.statistics.bytes_hashed += 64;
-	++nblocks; ncount = 0;
+	++nblocks; 
+#ifdef TIGER_DBG
+	ncount = 0;
+#endif
         sl_memset(bbuf, 0, 56 ); 
       }
Index: /trunk/src/sh_tools.c
===================================================================
--- /trunk/src/sh_tools.c	(revision 382)
+++ /trunk/src/sh_tools.c	(revision 383)
@@ -339,5 +339,5 @@
 	    break;
 
-	  c = *p;
+
 
 	  switch (*p) {
@@ -516,5 +516,5 @@
 {
   sin_cache * check_cache = conn_cache;
-  sin_cache * old_entry   = conn_cache;
+  sin_cache * old_entry;
 
   SL_ENTER(_("delete_cache"));
Index: /trunk/src/sh_unix.c
===================================================================
--- /trunk/src/sh_unix.c	(revision 382)
+++ /trunk/src/sh_unix.c	(revision 383)
@@ -1108,5 +1108,5 @@
   int    status;
   int    level;
-  uid_t  ff_euid;
+  uid_t  ff_euid = (uid_t) -1;
 
   SL_ENTER(_("tf_trust_check"));
@@ -1136,5 +1136,8 @@
 	  aud_exit (FIL__, __LINE__, EXIT_FAILURE);
 	}
-      ff_euid = tempres->pw_uid;
+      else
+	{
+	  ff_euid = tempres->pw_uid;
+	}
 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R)
       SH_FREE(buffer);
@@ -2623,7 +2626,10 @@
 static void sh_userid_additem(struct user_id * list, struct user_id * item)
 {
-  while (list && list->next)
-    list = list->next;
-  list->next = item;
+  if (list)
+    {
+      while (list && list->next)
+	list = list->next;
+      list->next = item;
+    }
   return;
 }
Index: /trunk/src/sh_utmp.c
===================================================================
--- /trunk/src/sh_utmp.c	(revision 382)
+++ /trunk/src/sh_utmp.c	(revision 383)
@@ -872,4 +872,17 @@
   SL_ENTER(_("sh_utmp_addlogin"));
 
+  if (ut->ut_line[0] == '\0')
+    SL_RET0(_("sh_utmp_addlogin"));
+
+  /* for some stupid reason, AIX repeats the wtmp entry for logouts
+   * with ssh
+   */
+  if (memcmp (&save_utmp, ut, sizeof(struct SH_UTMP_S)) == 0)
+    {
+      memset(&save_utmp, (int) '\0', sizeof(struct SH_UTMP_S));
+      SL_RET0(_("sh_utmp_addlogin"));
+    }
+  memcpy (&save_utmp, ut, sizeof(struct SH_UTMP_S));
+
   /* Take the address to keep gcc from putting them into registers. 
    * Avoids the 'clobbered by longjmp' warning. 
@@ -877,18 +890,4 @@
   sh_dummy_userold = (void*) &userold;
   sh_dummy_user    = (void*) &user;
-
-  if (ut->ut_line[0] == '\0')
-    SL_RET0(_("sh_utmp_addlogin"));
-
-  /* for some stupid reason, AIX repeats the wtmp entry for logouts
-   * with ssh
-   */
-  if (memcmp (&save_utmp, ut, sizeof(struct SH_UTMP_S)) == 0)
-    {
-      memset(&save_utmp, (int) '\0', sizeof(struct SH_UTMP_S));
-      SL_RET0(_("sh_utmp_addlogin"));
-    }
-  memcpy (&save_utmp, ut, sizeof(struct SH_UTMP_S));
-
 
   /* ------- find user -------- 
@@ -993,5 +992,5 @@
       
       sh_utmp_login_morechecks(ut);
-      SL_RET0(_("sh_utmp_addlogin"));
+      goto out;
     }
 
@@ -1052,9 +1051,9 @@
 	  SH_MUTEX_UNLOCK(mutex_thread_nolog);
 	}
-      SL_RET0(_("sh_utmp_addlogin"));
+      goto out;
     }
 
   /* default */
-  SL_RET0(_("sh_utmp_addlogin"));
+  goto out;
 
   /* #ifdef HAVE_UTTYPE                   */
@@ -1136,6 +1135,11 @@
     }
 
+#endif
+
+ out:
+  sh_dummy_user    = NULL;
+  sh_dummy_userold = NULL;
+
   SL_RET0(_("sh_utmp_addlogin"));
-#endif
 }
 
@@ -1214,5 +1218,5 @@
     {
       while (this_read < lastread) {
-	ut = sh_utmp_getutent();
+	(void) sh_utmp_getutent();
 	++this_read;
       }
Index: /trunk/src/slib.c
===================================================================
--- /trunk/src/slib.c	(revision 382)
+++ /trunk/src/slib.c	(revision 383)
@@ -931,5 +931,5 @@
   else if (src == NULL)
     {
-      if (siz > 0) 
+      if (dst && siz > 0) 
 	dst[0] = '\0';
       return SL_ENONE;
@@ -2835,8 +2835,10 @@
    */
   bytecount    = 0;
-  bytewritten  = 0;
+
   while (bytecount < nbytes) 
     {    
-      if ((bytewritten = write (fd, msg, nbytes-bytecount)) > 0) 
+      bytewritten = write (fd, msg, nbytes-bytecount);
+
+      if (bytewritten > 0) 
 	{
 	  bytecount += bytewritten;
Index: /trunk/src/zAVLTree.c
===================================================================
--- /trunk/src/zAVLTree.c	(revision 382)
+++ /trunk/src/zAVLTree.c	(revision 383)
@@ -366,5 +366,5 @@
   depthdiff = R_DEPTH(avlnode) - L_DEPTH(avlnode);
 
-  if (depthdiff <= -2) {
+  if (depthdiff <= -2 && avlnode->left) {
     child = avlnode->left;
 
@@ -384,25 +384,28 @@
     else {
       gchild = child->right;
-      avlnode->left = gchild->right;
-      if (avlnode->left != NULL)
-        avlnode->left->parent = avlnode;
-      avlnode->depth = CALC_DEPTH(avlnode);
-      child->right = gchild->left;
-      if (child->right != NULL)
-        child->right->parent = child;
-      child->depth = CALC_DEPTH(child);
-      gchild->right = avlnode;
-      if (gchild->right != NULL)
-        gchild->right->parent = gchild;
-      gchild->left = child;
-      if (gchild->left != NULL)
-        gchild->left->parent = gchild;
-      gchild->depth = CALC_DEPTH(gchild);
-      *superparent = gchild;
-      gchild->parent = origparent;
-    }
-  }
-
-  else if (depthdiff >= 2) {
+      if (gchild)
+	{
+	  avlnode->left = gchild->right;
+	  if (avlnode->left != NULL)
+	    avlnode->left->parent = avlnode;
+	  avlnode->depth = CALC_DEPTH(avlnode);
+	  child->right = gchild->left;
+	  if (child->right != NULL)
+	    child->right->parent = child;
+	  child->depth = CALC_DEPTH(child);
+	  gchild->right = avlnode;
+	  if (gchild->right != NULL)
+	    gchild->right->parent = gchild;
+	  gchild->left = child;
+	  if (gchild->left != NULL)
+	    gchild->left->parent = gchild;
+	  gchild->depth = CALC_DEPTH(gchild);
+	  *superparent = gchild;
+	  gchild->parent = origparent;
+	}
+    }
+  }
+
+  else if (depthdiff >= 2 && avlnode->right) {
     child = avlnode->right;
 
@@ -422,21 +425,24 @@
     else {
       gchild = child->left;
-      avlnode->right = gchild->left;
-      if (avlnode->right != NULL)
-        avlnode->right->parent = avlnode;
-      avlnode->depth = CALC_DEPTH(avlnode);
-      child->left = gchild->right;
-      if (child->left != NULL)
-        child->left->parent = child;
-      child->depth = CALC_DEPTH(child);
-      gchild->left = avlnode;
-      if (gchild->left != NULL)
-        gchild->left->parent = gchild;
-      gchild->right = child;
-      if (gchild->right != NULL)
-        gchild->right->parent = gchild;
-      gchild->depth = CALC_DEPTH(gchild);
-      *superparent = gchild;
-      gchild->parent = origparent;
+      if (gchild)
+	{
+	  avlnode->right = gchild->left;
+	  if (avlnode->right != NULL)
+	    avlnode->right->parent = avlnode;
+	  avlnode->depth = CALC_DEPTH(avlnode);
+	  child->left = gchild->right;
+	  if (child->left != NULL)
+	    child->left->parent = child;
+	  child->depth = CALC_DEPTH(child);
+	  gchild->left = avlnode;
+	  if (gchild->left != NULL)
+	    gchild->left->parent = gchild;
+	  gchild->right = child;
+	  if (gchild->right != NULL)
+	    gchild->right->parent = gchild;
+	  gchild->depth = CALC_DEPTH(gchild);
+	  *superparent = gchild;
+	  gchild->parent = origparent;
+	}
     }
   }
