]> andersk Git - openssh.git/commitdiff
- djm@cvs.openbsd.org 2003/11/17 09:45:39
authordjm <djm>
Mon, 17 Nov 2003 10:20:47 +0000 (10:20 +0000)
committerdjm <djm>
Mon, 17 Nov 2003 10:20:47 +0000 (10:20 +0000)
     [msg.c msg.h sshconnect2.c ssh-keysign.c]
     return error on msg send/receive failure (rather than fatal); ok markus@

ChangeLog
msg.c
msg.h
ssh-keysign.c
sshconnect2.c

index d47b2a5942049e9593999b47bb8d35f524bb2ff2..db936faedcaab03fe76a7d4839924bb67585ca4e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/msg.c b/msg.c
index 6a806c3f5a1fec68d9a8a25bec8fe00b4cd2cf92..30bc3f1076385c8a599544342b870b0e684dbbbb 100644 (file)
--- a/msg.c
+++ b/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);
 }
diff --git a/msg.h b/msg.h
index c07df88a7acd4b66ad6627ff80481f04ab68513a..0d3ea065826ca4eb28d6a123e548999a85fcd09d 100644 (file)
--- a/msg.h
+++ b/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
index c7ca5c4e40094d35c5cf82fa4e291086a6c71d9f..b3db628c69c7bddb585461989a085507927e1335 100644 (file)
@@ -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);
 }
index 045f3081f6b4a692a4d728becc3fb4348201a49a..388a25741d7b976c44270ea80888bf3fe9e969f0 100644 (file)
@@ -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");
This page took 0.049352 seconds and 5 git commands to generate.