diff options
Diffstat (limited to 'msg.c')
-rw-r--r-- | msg.c | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -1,3 +1,4 @@ | |||
1 | /* $OpenBSD: msg.c,v 1.15 2006/08/03 03:34:42 deraadt Exp $ */ | ||
1 | /* | 2 | /* |
2 | * Copyright (c) 2002 Markus Friedl. All rights reserved. | 3 | * Copyright (c) 2002 Markus Friedl. All rights reserved. |
3 | * | 4 | * |
@@ -21,14 +22,23 @@ | |||
21 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
22 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
23 | */ | 24 | */ |
25 | |||
24 | #include "includes.h" | 26 | #include "includes.h" |
25 | RCSID("$OpenBSD: msg.c,v 1.8 2005/05/24 17:32:43 avsm Exp $"); | 27 | |
28 | #include <sys/types.h> | ||
29 | #include <sys/uio.h> | ||
30 | |||
31 | #include <errno.h> | ||
32 | #include <stdio.h> | ||
33 | #include <string.h> | ||
34 | #include <unistd.h> | ||
35 | #include <stdarg.h> | ||
26 | 36 | ||
27 | #include "buffer.h" | 37 | #include "buffer.h" |
28 | #include "getput.h" | ||
29 | #include "log.h" | 38 | #include "log.h" |
30 | #include "atomicio.h" | 39 | #include "atomicio.h" |
31 | #include "msg.h" | 40 | #include "msg.h" |
41 | #include "misc.h" | ||
32 | 42 | ||
33 | int | 43 | int |
34 | ssh_msg_send(int fd, u_char type, Buffer *m) | 44 | ssh_msg_send(int fd, u_char type, Buffer *m) |
@@ -38,7 +48,7 @@ ssh_msg_send(int fd, u_char type, Buffer *m) | |||
38 | 48 | ||
39 | debug3("ssh_msg_send: type %u", (unsigned int)type & 0xff); | 49 | debug3("ssh_msg_send: type %u", (unsigned int)type & 0xff); |
40 | 50 | ||
41 | PUT_32BIT(buf, mlen + 1); | 51 | put_u32(buf, mlen + 1); |
42 | buf[4] = type; /* 1st byte of payload is mesg-type */ | 52 | buf[4] = type; /* 1st byte of payload is mesg-type */ |
43 | if (atomicio(vwrite, fd, buf, sizeof(buf)) != sizeof(buf)) { | 53 | if (atomicio(vwrite, fd, buf, sizeof(buf)) != sizeof(buf)) { |
44 | error("ssh_msg_send: write"); | 54 | error("ssh_msg_send: write"); |
@@ -64,7 +74,7 @@ ssh_msg_recv(int fd, Buffer *m) | |||
64 | error("ssh_msg_recv: read: header"); | 74 | error("ssh_msg_recv: read: header"); |
65 | return (-1); | 75 | return (-1); |
66 | } | 76 | } |
67 | msg_len = GET_32BIT(buf); | 77 | msg_len = get_u32(buf); |
68 | if (msg_len > 256 * 1024) { | 78 | if (msg_len > 256 * 1024) { |
69 | error("ssh_msg_recv: read: bad msg_len %u", msg_len); | 79 | error("ssh_msg_recv: read: bad msg_len %u", msg_len); |
70 | return (-1); | 80 | return (-1); |