From 24f8f368ebee5b7724f4b046a1f28066ffd9223f Mon Sep 17 00:00:00 2001 From: james Date: Thu, 17 Jul 2008 04:25:50 +0000 Subject: Fixed issue in read_key_file, where the return value of 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 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crypto.c b/crypto.c index ebb7981..9868528 100644 --- 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; -- cgit v1.2.3