diff options
| author | 2015-01-15 09:40:00 +0000 | |
|---|---|---|
| committer | 2015-01-15 09:40:00 +0000 | |
| commit | 2aa7d2208a574010463f7eba5ed602c0b36ee122 (patch) | |
| tree | 43f4e9209b627f6445105f0839f46ba1e559b163 /usr.bin/ssh/msg.c | |
| parent | Extend the description of _timeout. (diff) | |
| download | wireguard-openbsd-2aa7d2208a574010463f7eba5ed602c0b36ee122.tar.xz wireguard-openbsd-2aa7d2208a574010463f7eba5ed602c0b36ee122.zip | |
sync ssh-keysign, ssh-keygen and some dependencies to the new
buffer/key API; mostly mechanical, ok markus@
Diffstat (limited to 'usr.bin/ssh/msg.c')
| -rw-r--r-- | usr.bin/ssh/msg.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/usr.bin/ssh/msg.c b/usr.bin/ssh/msg.c index 8b82b2ecf97..cf73ba4af17 100644 --- a/usr.bin/ssh/msg.c +++ b/usr.bin/ssh/msg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: msg.c,v 1.15 2006/08/03 03:34:42 deraadt Exp $ */ +/* $OpenBSD: msg.c,v 1.16 2015/01/15 09:40:00 djm Exp $ */ /* * Copyright (c) 2002 Markus Friedl. All rights reserved. * @@ -32,17 +32,18 @@ #include <unistd.h> #include <stdarg.h> -#include "buffer.h" +#include "sshbuf.h" +#include "ssherr.h" #include "log.h" #include "atomicio.h" #include "msg.h" #include "misc.h" int -ssh_msg_send(int fd, u_char type, Buffer *m) +ssh_msg_send(int fd, u_char type, struct sshbuf *m) { u_char buf[5]; - u_int mlen = buffer_len(m); + u_int mlen = sshbuf_len(m); debug3("ssh_msg_send: type %u", (unsigned int)type & 0xff); @@ -52,7 +53,7 @@ ssh_msg_send(int fd, u_char type, Buffer *m) error("ssh_msg_send: write"); return (-1); } - if (atomicio(vwrite, fd, buffer_ptr(m), mlen) != mlen) { + if (atomicio(vwrite, fd, (u_char *)sshbuf_ptr(m), mlen) != mlen) { error("ssh_msg_send: write"); return (-1); } @@ -60,10 +61,11 @@ ssh_msg_send(int fd, u_char type, Buffer *m) } int -ssh_msg_recv(int fd, Buffer *m) +ssh_msg_recv(int fd, struct sshbuf *m) { - u_char buf[4]; + u_char buf[4], *p; u_int msg_len; + int r; debug3("ssh_msg_recv entering"); @@ -77,9 +79,12 @@ ssh_msg_recv(int fd, Buffer *m) error("ssh_msg_recv: read: bad msg_len %u", msg_len); return (-1); } - buffer_clear(m); - buffer_append_space(m, msg_len); - if (atomicio(read, fd, buffer_ptr(m), msg_len) != msg_len) { + sshbuf_reset(m); + if ((r = sshbuf_reserve(m, msg_len, &p)) != 0) { + error("%s: buffer error: %s", __func__, ssh_err(r)); + return -1; + } + if (atomicio(read, fd, p, msg_len) != msg_len) { error("ssh_msg_recv: read: %s", strerror(errno)); return (-1); } |
