summaryrefslogtreecommitdiff
path: root/monitor_wrap.c
diff options
context:
space:
mode:
Diffstat (limited to 'monitor_wrap.c')
-rw-r--r--monitor_wrap.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/monitor_wrap.c b/monitor_wrap.c
index e1b6512b4..1489e7f08 100644
--- a/monitor_wrap.c
+++ b/monitor_wrap.c
@@ -25,7 +25,7 @@
25 */ 25 */
26 26
27#include "includes.h" 27#include "includes.h"
28RCSID("$OpenBSD: monitor_wrap.c,v 1.39 2004/07/17 05:31:41 dtucker Exp $"); 28RCSID("$OpenBSD: monitor_wrap.c,v 1.40 2005/05/24 17:32:43 avsm Exp $");
29 29
30#include <openssl/bn.h> 30#include <openssl/bn.h>
31#include <openssl/dh.h> 31#include <openssl/dh.h>
@@ -95,9 +95,9 @@ mm_request_send(int sock, enum monitor_reqtype type, Buffer *m)
95 PUT_32BIT(buf, mlen + 1); 95 PUT_32BIT(buf, mlen + 1);
96 buf[4] = (u_char) type; /* 1st byte of payload is mesg-type */ 96 buf[4] = (u_char) type; /* 1st byte of payload is mesg-type */
97 if (atomicio(vwrite, sock, buf, sizeof(buf)) != sizeof(buf)) 97 if (atomicio(vwrite, sock, buf, sizeof(buf)) != sizeof(buf))
98 fatal("%s: write", __func__); 98 fatal("%s: write: %s", __func__, strerror(errno));
99 if (atomicio(vwrite, sock, buffer_ptr(m), mlen) != mlen) 99 if (atomicio(vwrite, sock, buffer_ptr(m), mlen) != mlen)
100 fatal("%s: write", __func__); 100 fatal("%s: write: %s", __func__, strerror(errno));
101} 101}
102 102
103void 103void
@@ -105,24 +105,21 @@ mm_request_receive(int sock, Buffer *m)
105{ 105{
106 u_char buf[4]; 106 u_char buf[4];
107 u_int msg_len; 107 u_int msg_len;
108 ssize_t res;
109 108
110 debug3("%s entering", __func__); 109 debug3("%s entering", __func__);
111 110
112 res = atomicio(read, sock, buf, sizeof(buf)); 111 if (atomicio(read, sock, buf, sizeof(buf)) != sizeof(buf)) {
113 if (res != sizeof(buf)) { 112 if (errno == EPIPE)
114 if (res == 0)
115 cleanup_exit(255); 113 cleanup_exit(255);
116 fatal("%s: read: %ld", __func__, (long)res); 114 fatal("%s: read: %s", __func__, strerror(errno));
117 } 115 }
118 msg_len = GET_32BIT(buf); 116 msg_len = GET_32BIT(buf);
119 if (msg_len > 256 * 1024) 117 if (msg_len > 256 * 1024)
120 fatal("%s: read: bad msg_len %d", __func__, msg_len); 118 fatal("%s: read: bad msg_len %d", __func__, msg_len);
121 buffer_clear(m); 119 buffer_clear(m);
122 buffer_append_space(m, msg_len); 120 buffer_append_space(m, msg_len);
123 res = atomicio(read, sock, buffer_ptr(m), msg_len); 121 if (atomicio(read, sock, buffer_ptr(m), msg_len) != msg_len)
124 if (res != msg_len) 122 fatal("%s: read: %s", __func__, strerror(errno));
125 fatal("%s: read: %ld != msg_len", __func__, (long)res);
126} 123}
127 124
128void 125void
@@ -767,7 +764,8 @@ mm_sshpam_query(void *ctx, char **name, char **info,
767 u_int *num, char ***prompts, u_int **echo_on) 764 u_int *num, char ***prompts, u_int **echo_on)
768{ 765{
769 Buffer m; 766 Buffer m;
770 int i, ret; 767 u_int i;
768 int ret;
771 769
772 debug3("%s", __func__); 770 debug3("%s", __func__);
773 buffer_init(&m); 771 buffer_init(&m);
@@ -793,7 +791,8 @@ int
793mm_sshpam_respond(void *ctx, u_int num, char **resp) 791mm_sshpam_respond(void *ctx, u_int num, char **resp)
794{ 792{
795 Buffer m; 793 Buffer m;
796 int i, ret; 794 u_int i;
795 int ret;
797 796
798 debug3("%s", __func__); 797 debug3("%s", __func__);
799 buffer_init(&m); 798 buffer_init(&m);