]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Close the listening socket when a sharing upstream dies.
authorSimon Tatham <anakin@pobox.com>
Sun, 7 Sep 2014 13:06:52 +0000 (13:06 +0000)
committerSimon Tatham <anakin@pobox.com>
Sun, 7 Sep 2014 13:06:52 +0000 (13:06 +0000)
Without this, doing 'Restart Session' on Windows in a session with
sharing enabled but no actual sharing being done would crash, because
the first incarnation of the session would become an upstream and
establish a listening named pipe, which then wouldn't get cleaned up
when the session closed, so the restarted session would try to connect
to it, triggering a call to plug_accepting on a freed sharestate.

[originally from svn r10216]

sshshare.c

index bf2a64c2925e382f2a91cdfd7cba008bf6b6be85..5b88eb8ed1d3965795ce35788727916e30db3243 100644 (file)
@@ -517,6 +517,10 @@ void sharestate_free(void *v)
         share_connstate_free(cs);
     }
     freetree234(sharestate->connections);
+    if (sharestate->listensock) {
+        sk_close(sharestate->listensock);
+        sharestate->listensock = NULL;
+    }
     sfree(sharestate->server_verstring);
     sfree(sharestate->sockname);
     sfree(sharestate);
@@ -1843,6 +1847,7 @@ static int share_listen_closing(Plug plug, const char *error_msg,
         ssh_sharing_logf(sharestate->ssh, 0,
                          "listening socket: %s", error_msg);
     sk_close(sharestate->listensock);
+    sharestate->listensock = NULL;
     return 1;
 }