View | Details | Raw Unified | Return to bug 406
Collapse All | Expand All

(-)msg.c (-9 / +9 lines)
Lines 31-73 Link Here
31
#include "msg.h"
31
#include "msg.h"
32
32
33
void
33
void
34
msg_send(int fd, u_char type, Buffer *m)
34
ssh_msg_send(int fd, u_char type, Buffer *m)
35
{
35
{
36
	u_char buf[5];
36
	u_char buf[5];
37
	u_int mlen = buffer_len(m);
37
	u_int mlen = buffer_len(m);
38
38
39
	debug3("msg_send: type %u", (unsigned int)type & 0xff);
39
	debug3("ssh_msg_send: type %u", (unsigned int)type & 0xff);
40
40
41
	PUT_32BIT(buf, mlen + 1);
41
	PUT_32BIT(buf, mlen + 1);
42
	buf[4] = type;		/* 1st byte of payload is mesg-type */
42
	buf[4] = type;		/* 1st byte of payload is mesg-type */
43
	if (atomicio(write, fd, buf, sizeof(buf)) != sizeof(buf))
43
	if (atomicio(write, fd, buf, sizeof(buf)) != sizeof(buf))
44
		fatal("msg_send: write");
44
		fatal("ssh_msg_send: write");
45
	if (atomicio(write, fd, buffer_ptr(m), mlen) != mlen)
45
	if (atomicio(write, fd, buffer_ptr(m), mlen) != mlen)
46
		fatal("msg_send: write");
46
		fatal("ssh_msg_send: write");
47
}
47
}
48
48
49
int
49
int
50
msg_recv(int fd, Buffer *m)
50
ssh_msg_recv(int fd, Buffer *m)
51
{
51
{
52
	u_char buf[4];
52
	u_char buf[4];
53
	ssize_t res;
53
	ssize_t res;
54
	u_int msg_len;
54
	u_int msg_len;
55
55
56
	debug3("msg_recv entering");
56
	debug3("ssh_msg_recv entering");
57
57
58
	res = atomicio(read, fd, buf, sizeof(buf));
58
	res = atomicio(read, fd, buf, sizeof(buf));
59
	if (res != sizeof(buf)) {
59
	if (res != sizeof(buf)) {
60
		if (res == 0)
60
		if (res == 0)
61
			return -1;
61
			return -1;
62
		fatal("msg_recv: read: header %ld", (long)res);
62
		fatal("ssh_msg_recv: read: header %ld", (long)res);
63
	}
63
	}
64
	msg_len = GET_32BIT(buf);
64
	msg_len = GET_32BIT(buf);
65
	if (msg_len > 256 * 1024)
65
	if (msg_len > 256 * 1024)
66
		fatal("msg_recv: read: bad msg_len %u", msg_len);
66
		fatal("ssh_msg_recv: read: bad msg_len %u", msg_len);
67
	buffer_clear(m);
67
	buffer_clear(m);
68
	buffer_append_space(m, msg_len);
68
	buffer_append_space(m, msg_len);
69
	res = atomicio(read, fd, buffer_ptr(m), msg_len);
69
	res = atomicio(read, fd, buffer_ptr(m), msg_len);
70
	if (res != msg_len)
70
	if (res != msg_len)
71
		fatal("msg_recv: read: %ld != msg_len", (long)res);
71
		fatal("ssh_msg_recv: read: %ld != msg_len", (long)res);
72
	return 0;
72
	return 0;
73
}
73
}
(-)msg.h (-2 / +2 lines)
Lines 25-31 Link Here
25
#ifndef SSH_MSG_H
25
#ifndef SSH_MSG_H
26
#define SSH_MSG_H
26
#define SSH_MSG_H
27
27
28
void	 msg_send(int, u_char, Buffer *);
28
void	 ssh_msg_send(int, u_char, Buffer *);
29
int	 msg_recv(int, Buffer *);
29
int	 ssh_msg_recv(int, Buffer *);
30
30
31
#endif
31
#endif
(-)ssh-keysign.c (-3 / +3 lines)
Lines 196-203 Link Here
196
		fatal("no hostkey found");
196
		fatal("no hostkey found");
197
197
198
	buffer_init(&b);
198
	buffer_init(&b);
199
	if (msg_recv(STDIN_FILENO, &b) < 0)
199
	if (ssh_msg_recv(STDIN_FILENO, &b) < 0)
200
		fatal("msg_recv failed");
200
		fatal("ssh_msg_recv failed");
201
	if (buffer_get_char(&b) != version)
201
	if (buffer_get_char(&b) != version)
202
		fatal("bad version");
202
		fatal("bad version");
203
	fd = buffer_get_int(&b);
203
	fd = buffer_get_int(&b);
Lines 229-235 Link Here
229
	/* send reply */
229
	/* send reply */
230
	buffer_clear(&b);
230
	buffer_clear(&b);
231
	buffer_put_string(&b, signature, slen);
231
	buffer_put_string(&b, signature, slen);
232
	msg_send(STDOUT_FILENO, version, &b);
232
	ssh_msg_send(STDOUT_FILENO, version, &b);
233
233
234
	return (0);
234
	return (0);
235
}
235
}
(-)sshconnect2.c (-2 / +2 lines)
Lines 947-955 Link Here
947
	buffer_init(&b);
947
	buffer_init(&b);
948
	buffer_put_int(&b, packet_get_connection_in()); /* send # of socket */
948
	buffer_put_int(&b, packet_get_connection_in()); /* send # of socket */
949
	buffer_put_string(&b, data, datalen);
949
	buffer_put_string(&b, data, datalen);
950
	msg_send(to[1], version, &b);
950
	ssh_msg_send(to[1], version, &b);
951
951
952
	if (msg_recv(from[0], &b) < 0) {
952
	if (ssh_msg_recv(from[0], &b) < 0) {
953
		error("ssh_keysign: no reply");
953
		error("ssh_keysign: no reply");
954
		buffer_clear(&b);
954
		buffer_clear(&b);
955
		return -1;
955
		return -1;

Return to bug 406