Prevent duplicate sk_close() calls on the same socket when the
[u/mdw/putty] / rlogin.c
index c77f381..850d906 100644 (file)
--- a/rlogin.c
+++ b/rlogin.c
@@ -24,13 +24,14 @@ static void c_write (char *buf, int len) {
     from_backend(0, buf, len);
 }
 
-static int rlogin_receive (Socket s, int urgent, char *data, int len) {
+static int rlogin_receive (Socket skt, int urgent, char *data, int len) {
     if (urgent==3) {
         /* A socket error has occurred. */
+        sk_close(s);
+        s = NULL;
         connection_fatal(data);
-        len = 0;
-    }
-    if (!len) {
+        return 0;
+    } else if (!len) {
        /* Connection has closed. */
        sk_close(s);
        s = NULL;
@@ -102,8 +103,6 @@ static char *rlogin_init (char *host, int port, char **realhost) {
         sk_write(s, &z, 1);
     }
 
-    begin_session();
-
     return NULL;
 }
 
@@ -142,6 +141,10 @@ static Socket rlogin_socket(void) { return s; }
 
 static int rlogin_sendok(void) { return 1; }
 
+static int rlogin_ldisc(int option) {
+    return 0;
+}
+
 Backend rlogin_backend = {
     rlogin_init,
     rlogin_send,
@@ -149,5 +152,6 @@ Backend rlogin_backend = {
     rlogin_special,
     rlogin_socket,
     rlogin_sendok,
+    rlogin_ldisc,
     1
 };