Index: trunk/src/samhain.c
===================================================================
--- trunk/src/samhain.c	(revision 151)
+++ trunk/src/samhain.c	(revision 153)
@@ -1391,6 +1391,7 @@
 	  my_argv[0] = argv[0]; ++my_argc;  
 	  command_line[0] = '\0';
-	  (void*) fgets (command_line, sizeof(command_line), stdin);
-	  command_line[sizeof(command_line)-1] = '\0';
+	  if (NULL != fgets (command_line, sizeof(command_line), stdin))
+	    command_line[sizeof(command_line)-1] = '\0';
+
 	  do {
 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_STRTOK_R)
@@ -1961,5 +1962,5 @@
 	      (void) sh_dirs_chk  (1);
 #ifndef SH_PROFILE
-	      (void) chdir ("/");
+	      (void) retry_aud_chdir (FIL__, __LINE__, "/");
 #endif
 	    }
@@ -1968,5 +1969,5 @@
 	      (void) sh_dirs_chk  (2); 
 #ifndef SH_PROFILE
-	      (void) chdir ("/");
+	      (void) retry_aud_chdir (FIL__, __LINE__, "/");
 #endif
 	    }
Index: trunk/src/sh_entropy.c
===================================================================
--- trunk/src/sh_entropy.c	(revision 151)
+++ trunk/src/sh_entropy.c	(revision 153)
@@ -618,9 +618,11 @@
       }
       
-      freopen (_("/dev/null"), "r+", stderr);
+      if (NULL != freopen (_("/dev/null"), "r+", stderr))
+	{
       
-      /* exec the program */
-      retry_aud_execve (FIL__, __LINE__, _("/bin/sh"), arg, envp);
-      
+	  /* exec the program */
+	  retry_aud_execve (FIL__, __LINE__, _("/bin/sh"), arg, envp);
+	}
+
       /* failed 
        */
Index: trunk/src/sh_err_console.c
===================================================================
--- trunk/src/sh_err_console.c	(revision 151)
+++ trunk/src/sh_err_console.c	(revision 153)
@@ -286,4 +286,5 @@
   struct sigaction sa_new, sa_old;
   static int blockMe = 0;
+  int    val_return;
 
   SL_ENTER(_("sh_log_console"));
@@ -315,6 +316,10 @@
     {
       len = strlen(errmsg);
-      (void) write(STDERR_FILENO, errmsg, len);
-      (void) write(STDERR_FILENO, "\n", 1);
+      do {
+	val_return = write(STDERR_FILENO, errmsg, len);
+      } while (val_return < 0 && errno == EINTR); 
+      do {
+	val_return = write(STDERR_FILENO, "\n", 1);
+      } while (val_return < 0 && errno == EINTR); 
       /* 
        * fprintf (stderr, "%s\n", errmsg); 
@@ -367,6 +372,10 @@
 	  if (fd[cc] >= 0)
 	    {
-	      (void) write(fd[cc], errmsg, strlen(errmsg));
-	      (void) write(fd[cc], "\r\n",              2);
+	      do {
+		val_return = write(fd[cc], errmsg, strlen(errmsg));
+	      } while (val_return < 0 && errno == EINTR);
+	      do {
+		val_return = write(fd[cc], "\r\n",              2);
+	      } while (val_return < 0 && errno == EINTR);
 	      (void) close(fd[cc]);
 	      service_failure[cc] = 0;
Index: trunk/src/sh_err_log.c
===================================================================
--- trunk/src/sh_err_log.c	(revision 151)
+++ trunk/src/sh_err_log.c	(revision 153)
@@ -392,15 +392,17 @@
 		  (void) fflush(stdout); 
 		  key[0] = '\0';
-		  (void) fgets(key, sizeof(key), stdin);
-		  if (key[0] != '\n') 
+		  if (NULL != fgets(key, sizeof(key), stdin))
 		    {
-		      if (key[strlen(key) - 1] == '\n')
-			key[strlen(key) - 1] = '\0';
-		    }
-		  if (key[0] == '/')
-		    {
-		      chk_mode = CHK_FIL;
-		      (void) sl_strlcpy(path, key, KEY_LEN+1); 
-		      break;
+		      if (key[0] != '\n') 
+			{
+			  if (key[strlen(key) - 1] == '\n')
+			    key[strlen(key) - 1] = '\0';
+			}
+		      if (key[0] == '/')
+			{
+			  chk_mode = CHK_FIL;
+			  (void) sl_strlcpy(path, key, KEY_LEN+1); 
+			  break;
+			}
 		    }
 		}
Index: trunk/src/sh_gpg.c
===================================================================
--- trunk/src/sh_gpg.c	(revision 151)
+++ trunk/src/sh_gpg.c	(revision 153)
@@ -489,5 +489,9 @@
       sh_unix_closeall (3, -1); /* in child process */
 
-      freopen(_("/dev/null"), "r+", stderr); 
+      if (NULL == freopen(_("/dev/null"), "r+", stderr))
+	{
+	  dlog(1, FIL__, __LINE__, _("Internal error: freopen failed\n"));
+	  aud__exit(FIL__, __LINE__, EXIT_FAILURE);
+	}
 
       /* We should become privileged if SUID,
Index: trunk/src/sh_hash.c
===================================================================
--- trunk/src/sh_hash.c	(revision 151)
+++ trunk/src/sh_hash.c	(revision 153)
@@ -459,4 +459,5 @@
 
  unlock_and_return:
+  ; /* 'label at end of compound statement */
   SH_MUTEX_UNLOCK(mutex_hash);
   return retval;
@@ -1349,4 +1350,5 @@
 
  unlock_and_return:
+  ; /* 'label at end of compound statement */
   SH_MUTEX_UNLOCK(mutex_hash);
   SL_RET0(_("sh_hash_init"));
@@ -1377,4 +1379,5 @@
 
  unlock_and_exit:
+  ; /* 'label at end of compound statement */
   SH_MUTEX_UNLOCK(mutex_hash);
   SL_RET0(_("sh_hash_hashdelete"));
@@ -1792,9 +1795,16 @@
 	sl_write_line_fast (pushdata_fd, attr_string, sl_strlen(attr_string));
     } else {
-      fwrite (&p, sizeof(sh_filestore_t), 1, stdout);
-      printf ("%s\n", fullpath);
-      printf ("%s\n", linkpath);
-      if (attr_string)
-	printf ("%s\n", attr_string);
+      if (fwrite (&p, sizeof(sh_filestore_t), 1, stdout))
+	{
+	  printf ("%s\n", fullpath);
+	  printf ("%s\n", linkpath);
+	  if (attr_string)
+	    printf ("%s\n", attr_string);
+	}
+      else
+	{
+	  perror(_("Error writing database"));
+	  aud_exit (FIL__, __LINE__, EXIT_FAILURE);
+	}
     }
 
@@ -2728,5 +2738,5 @@
 
   char log_policy[32];
-  int  log_severity;
+  volatile int  log_severity;
   char hashbuf[KEYBUF_SIZE];
 
@@ -3504,5 +3514,5 @@
 
  unlock_and_return:
-
+  ; /* 'label at end of compound statement */
   SH_MUTEX_UNLOCK(mutex_hash);
   SL_RETURN(retval, _("sh_hash_compdata"));
Index: trunk/src/sh_mem.c
===================================================================
--- trunk/src/sh_mem.c	(revision 151)
+++ trunk/src/sh_mem.c	(revision 153)
@@ -260,7 +260,7 @@
 void sh_mem_free (void * a, char * file, int line)
 {
-  memlist_t * this   = memlist;
-  memlist_t * before = memlist;
-  unsigned long size = 0;
+  volatile memlist_t * this   = memlist;
+  memlist_t          * before = memlist;
+  unsigned long        size   = 0;
 
   SL_ENTER(_("sh_mem_free"));
Index: trunk/src/sh_unix.c
===================================================================
--- trunk/src/sh_unix.c	(revision 151)
+++ trunk/src/sh_unix.c	(revision 153)
@@ -411,6 +411,11 @@
 #define STDERR_FILENO 2
 #endif
-    write(STDERR_FILENO,  msg, strlen(msg));
-    write(STDERR_FILENO, "\n", 1);
+    int retval = 0;
+    do {
+      retval = write(STDERR_FILENO,  msg, strlen(msg));
+    } while (retval < 0 && errno == EINTR);
+    do {
+      retval = write(STDERR_FILENO, "\n", 1);
+    } while (retval < 0 && errno == EINTR);
     return 0;
   }
@@ -468,5 +473,5 @@
   }
   sl_strlcat(msg, details, 128);
-  safe_logger (signal, method, msg);
+  (void) safe_logger (signal, method, msg);
   _exit(EXIT_FAILURE);
 }
@@ -507,5 +512,10 @@
       if (immediate_exit_normal == 2)
 	{
-	  chdir ("/");
+	  int val_return;
+
+	  do {
+	    val_return = chdir ("/");
+	  } while (val_return < 0 && errno == EINTR);
+
 	  safe_logger (mysignal, 0, NULL);
 	}
@@ -3032,6 +3042,7 @@
     {
       char hashbuf[KEYBUF_SIZE];
+      UINT64 local_length = (UINT64) (tmpFile.size < 0 ? 0 : tmpFile.size);
       sl_strlcpy(fileHash,
-		 sh_tiger_generic_hash (filename, fd, &(tmpFile.size), 
+		 sh_tiger_generic_hash (filename, fd, &(local_length), 
 					alert_timeout, hashbuf, sizeof(hashbuf)),
 		 KEY_LEN+1);
Index: trunk/src/sh_utmp.c
===================================================================
--- trunk/src/sh_utmp.c	(revision 151)
+++ trunk/src/sh_utmp.c	(revision 153)
@@ -773,6 +773,6 @@
 static void sh_utmp_addlogin (struct SH_UTMP_S * ut)
 {
-  struct log_user   * user     = userlist;
-  struct log_user   * userold  = userlist;
+  struct          log_user   * user     = userlist;
+  volatile struct log_user   * userold  = userlist;
 #ifdef HAVE_UTTYPE  
   struct log_user   * username = userlist;
@@ -781,5 +781,5 @@
   char   ttt[TIM_MAX];
 #ifdef HAVE_UTTYPE
-  int    status;
+  volatile int    status;
 #endif
 
