summaryrefslogtreecommitdiff
path: root/msg.c
diff options
context:
space:
mode:
Diffstat (limited to 'msg.c')
-rw-r--r--msg.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/msg.c b/msg.c
index 30bc3f107..3e4c2882c 100644
--- a/msg.c
+++ b/msg.c
@@ -22,7 +22,7 @@
22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */ 23 */
24#include "includes.h" 24#include "includes.h"
25RCSID("$OpenBSD: msg.c,v 1.7 2003/11/17 09:45:39 djm Exp $"); 25RCSID("$OpenBSD: msg.c,v 1.8 2005/05/24 17:32:43 avsm Exp $");
26 26
27#include "buffer.h" 27#include "buffer.h"
28#include "getput.h" 28#include "getput.h"
@@ -55,15 +55,13 @@ int
55ssh_msg_recv(int fd, Buffer *m) 55ssh_msg_recv(int fd, Buffer *m)
56{ 56{
57 u_char buf[4]; 57 u_char buf[4];
58 ssize_t res;
59 u_int msg_len; 58 u_int msg_len;
60 59
61 debug3("ssh_msg_recv entering"); 60 debug3("ssh_msg_recv entering");
62 61
63 res = atomicio(read, fd, buf, sizeof(buf)); 62 if (atomicio(read, fd, buf, sizeof(buf)) != sizeof(buf)) {
64 if (res != sizeof(buf)) { 63 if (errno != EPIPE)
65 if (res != 0) 64 error("ssh_msg_recv: read: header");
66 error("ssh_msg_recv: read: header %ld", (long)res);
67 return (-1); 65 return (-1);
68 } 66 }
69 msg_len = GET_32BIT(buf); 67 msg_len = GET_32BIT(buf);
@@ -73,9 +71,8 @@ ssh_msg_recv(int fd, Buffer *m)
73 } 71 }
74 buffer_clear(m); 72 buffer_clear(m);
75 buffer_append_space(m, msg_len); 73 buffer_append_space(m, msg_len);
76 res = atomicio(read, fd, buffer_ptr(m), msg_len); 74 if (atomicio(read, fd, buffer_ptr(m), msg_len) != msg_len) {
77 if (res != msg_len) { 75 error("ssh_msg_recv: read: %s", strerror(errno));
78 error("ssh_msg_recv: read: %ld != msg_len", (long)res);
79 return (-1); 76 return (-1);
80 } 77 }
81 return (0); 78 return (0);