Index: trunk/src/exepack.c
===================================================================
--- trunk/src/exepack.c	(revision 455)
+++ trunk/src/exepack.c	(revision 456)
@@ -84,4 +84,5 @@
 {
   int file;
+  long result;
 
   unsigned long i    = argc; /* dummy use of argc to fix compiler warning */
@@ -129,4 +130,5 @@
   out_len = (unsigned long) programlen_compressed_0;
   len     = (unsigned long) programlen_0;
+  in_len  = len;
 
   outbuf  = program_0;
@@ -260,5 +262,9 @@
     } 
 
-  write(file, inbuf, in_len);
+  result = (long) write(file, inbuf, in_len);
+  if (result < 0 || in_len != (lzo_uint) result)
+    {
+      return (5);
+    }
 
 #if defined(__linux__)
@@ -266,5 +272,5 @@
   if ( 0 != fstat(file, &sbuf))
     {
-      return (5);
+      return (6);
     } 
   
@@ -276,5 +282,5 @@
   if ( 0 != fstat(file, &fbuf))
     {
-      return (6);
+      return (7);
     } 
 
@@ -288,5 +294,5 @@
     {
       close  ( file );
-      return ( 6 );
+      return ( 8 );
     }
   
@@ -312,5 +318,5 @@
       fcntl  (file, F_SETFD, FD_CLOEXEC);
       execve (pname, argv, environ); 
-      return (8);
+      return (9);
     }
 #endif
@@ -325,5 +331,5 @@
       execve (fname, argv, environ);
       unlink (fname);
-      return (9);
+      return (10);
     } 
   else if (i == 0)
Index: trunk/src/exepack_fill.c
===================================================================
--- trunk/src/exepack_fill.c	(revision 455)
+++ trunk/src/exepack_fill.c	(revision 456)
@@ -169,5 +169,5 @@
 {
   FILE * fd;
-  long   clen;
+  unsigned long   clen;
   char * data;
   struct stat sbuf;
@@ -222,5 +222,6 @@
     return (-1);
 
-  fread  (data, 1, clen, fd);
+  if (clen != fread  (data, 1, clen, fd))
+    return (-1);
   fclose (fd);
 
@@ -337,5 +338,5 @@
       return (8);
     }
-  status = replaceData (data, clen, "CONTAINER", outbuf, out_len);
+  status = replaceData (data, clen, "CONTAINER", (char *) outbuf, out_len);
   if (status < 0)
     {
