mirror of
git://anongit.mindrot.org/openssh.git
synced 2024-12-22 10:00:14 +00:00
- djm@cvs.openbsd.org 2003/11/17 09:45:39
[msg.c msg.h sshconnect2.c ssh-keysign.c] return error on msg send/receive failure (rather than fatal); ok markus@
This commit is contained in:
parent
91c6aa4468
commit
51bf11fcc9
@ -40,6 +40,9 @@
|
||||
- markus@cvs.openbsd.org 2003/11/14 13:19:09
|
||||
[sshconnect2.c]
|
||||
cleanup and minor fixes for the client code; from Simon Wilkinson
|
||||
- djm@cvs.openbsd.org 2003/11/17 09:45:39
|
||||
[msg.c msg.h sshconnect2.c ssh-keysign.c]
|
||||
return error on msg send/receive failure (rather than fatal); ok markus@
|
||||
|
||||
20031115
|
||||
- (dtucker) [regress/agent-ptrace.sh] Test for GDB output from Solaris and
|
||||
@ -1460,4 +1463,4 @@
|
||||
- Fix sshd BindAddress and -b options for systems using fake-getaddrinfo.
|
||||
Report from murple@murple.net, diagnosis from dtucker@zip.com.au
|
||||
|
||||
$Id: ChangeLog,v 1.3108 2003/11/17 10:20:18 djm Exp $
|
||||
$Id: ChangeLog,v 1.3109 2003/11/17 10:20:47 djm Exp $
|
||||
|
37
msg.c
37
msg.c
@ -22,7 +22,7 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "includes.h"
|
||||
RCSID("$OpenBSD: msg.c,v 1.6 2003/06/28 16:23:06 deraadt Exp $");
|
||||
RCSID("$OpenBSD: msg.c,v 1.7 2003/11/17 09:45:39 djm Exp $");
|
||||
|
||||
#include "buffer.h"
|
||||
#include "getput.h"
|
||||
@ -30,7 +30,7 @@ RCSID("$OpenBSD: msg.c,v 1.6 2003/06/28 16:23:06 deraadt Exp $");
|
||||
#include "atomicio.h"
|
||||
#include "msg.h"
|
||||
|
||||
void
|
||||
int
|
||||
ssh_msg_send(int fd, u_char type, Buffer *m)
|
||||
{
|
||||
u_char buf[5];
|
||||
@ -40,10 +40,15 @@ ssh_msg_send(int fd, u_char type, Buffer *m)
|
||||
|
||||
PUT_32BIT(buf, mlen + 1);
|
||||
buf[4] = type; /* 1st byte of payload is mesg-type */
|
||||
if (atomicio(vwrite, fd, buf, sizeof(buf)) != sizeof(buf))
|
||||
fatal("ssh_msg_send: write");
|
||||
if (atomicio(vwrite, fd, buffer_ptr(m), mlen) != mlen)
|
||||
fatal("ssh_msg_send: write");
|
||||
if (atomicio(vwrite, fd, buf, sizeof(buf)) != sizeof(buf)) {
|
||||
error("ssh_msg_send: write");
|
||||
return (-1);
|
||||
}
|
||||
if (atomicio(vwrite, fd, buffer_ptr(m), mlen) != mlen) {
|
||||
error("ssh_msg_send: write");
|
||||
return (-1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
@ -57,17 +62,21 @@ ssh_msg_recv(int fd, Buffer *m)
|
||||
|
||||
res = atomicio(read, fd, buf, sizeof(buf));
|
||||
if (res != sizeof(buf)) {
|
||||
if (res == 0)
|
||||
return -1;
|
||||
fatal("ssh_msg_recv: read: header %ld", (long)res);
|
||||
if (res != 0)
|
||||
error("ssh_msg_recv: read: header %ld", (long)res);
|
||||
return (-1);
|
||||
}
|
||||
msg_len = GET_32BIT(buf);
|
||||
if (msg_len > 256 * 1024)
|
||||
fatal("ssh_msg_recv: read: bad msg_len %u", msg_len);
|
||||
if (msg_len > 256 * 1024) {
|
||||
error("ssh_msg_recv: read: bad msg_len %u", msg_len);
|
||||
return (-1);
|
||||
}
|
||||
buffer_clear(m);
|
||||
buffer_append_space(m, msg_len);
|
||||
res = atomicio(read, fd, buffer_ptr(m), msg_len);
|
||||
if (res != msg_len)
|
||||
fatal("ssh_msg_recv: read: %ld != msg_len", (long)res);
|
||||
return 0;
|
||||
if (res != msg_len) {
|
||||
error("ssh_msg_recv: read: %ld != msg_len", (long)res);
|
||||
return (-1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
4
msg.h
4
msg.h
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: msg.h,v 1.2 2002/12/19 00:07:02 djm Exp $ */
|
||||
/* $OpenBSD: msg.h,v 1.3 2003/11/17 09:45:39 djm Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2002 Markus Friedl. All rights reserved.
|
||||
*
|
||||
@ -25,7 +25,7 @@
|
||||
#ifndef SSH_MSG_H
|
||||
#define SSH_MSG_H
|
||||
|
||||
void ssh_msg_send(int, u_char, Buffer *);
|
||||
int ssh_msg_send(int, u_char, Buffer *);
|
||||
int ssh_msg_recv(int, Buffer *);
|
||||
|
||||
#endif
|
||||
|
@ -22,7 +22,7 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "includes.h"
|
||||
RCSID("$OpenBSD: ssh-keysign.c,v 1.13 2003/07/03 08:09:06 djm Exp $");
|
||||
RCSID("$OpenBSD: ssh-keysign.c,v 1.14 2003/11/17 09:45:39 djm Exp $");
|
||||
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/rand.h>
|
||||
@ -233,7 +233,8 @@ main(int argc, char **argv)
|
||||
/* send reply */
|
||||
buffer_clear(&b);
|
||||
buffer_put_string(&b, signature, slen);
|
||||
ssh_msg_send(STDOUT_FILENO, version, &b);
|
||||
if (ssh_msg_send(STDOUT_FILENO, version, &b) == -1)
|
||||
fatal("ssh_msg_send failed");
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
RCSID("$OpenBSD: sshconnect2.c,v 1.130 2003/11/14 13:19:09 markus Exp $");
|
||||
RCSID("$OpenBSD: sshconnect2.c,v 1.131 2003/11/17 09:45:39 djm Exp $");
|
||||
|
||||
#include "openbsd-compat/sys-queue.h"
|
||||
|
||||
@ -1240,7 +1240,8 @@ ssh_keysign(Key *key, u_char **sigp, u_int *lenp,
|
||||
buffer_init(&b);
|
||||
buffer_put_int(&b, packet_get_connection_in()); /* send # of socket */
|
||||
buffer_put_string(&b, data, datalen);
|
||||
ssh_msg_send(to[1], version, &b);
|
||||
if (ssh_msg_send(to[1], version, &b) == -1)
|
||||
fatal("ssh_keysign: couldn't send request");
|
||||
|
||||
if (ssh_msg_recv(from[0], &b) < 0) {
|
||||
error("ssh_keysign: no reply");
|
||||
|
Loading…
Reference in New Issue
Block a user