]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Fixed issue in read_key_file, where the return value of
authorjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>
Thu, 17 Jul 2008 04:25:50 +0000 (04:25 +0000)
committerjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>
Thu, 17 Jul 2008 04:25:50 +0000 (04:25 +0000)
read() wasn't being checked for errors.

git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@3063 e7ae566f-a301-0410-adde-c780ea21d3b5

crypto.c

index ebb798148626986011b0d930d448619c5e3a39de..986852843fd39afbc061ce59e6c7fe5fc35369e0 100644 (file)
--- a/crypto.c
+++ b/crypto.c
@@ -1052,13 +1052,15 @@ read_key_file (struct key2 *key2, const char *file, const unsigned int flags)
       if (fd == -1)
        msg (M_ERR, "Cannot open file key file '%s'", file);
       size = read (fd, in.data, in.capacity);
+      if (size < 0)
+       msg (M_FATAL, "Read error on key file ('%s')", file);
       if (size == in.capacity)
        msg (M_FATAL, "Key file ('%s') can be a maximum of %d bytes", file, (int)in.capacity);
       close (fd);
     }
 
   cp = (unsigned char *)in.data;
-  while (size)
+  while (size > 0)
     {
       const unsigned char c = *cp;