]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Initialise the random state in ssh_test_for_upstream().
authorSimon Tatham <anakin@pobox.com>
Sat, 24 Oct 2015 15:44:37 +0000 (16:44 +0100)
committerSimon Tatham <anakin@pobox.com>
Sat, 24 Oct 2015 15:44:37 +0000 (16:44 +0100)
This protects the Unix platform sharing code in the case where no salt
file exists yet in the connection-sharing directory, in which case
make_dirname() will want to create one by using some random bytes, and
prior to this commit, would fail an assertion because the random
number generator wasn't set up.

It would be neater to just return FALSE from ssh_test_for_upstream in
that situation - if there's no salt file, then no sharing socket can
be valid anyway - but that would involve doing more violence to the
code structure than I'm currently prepared to do for a minor elegance
gain.

ssh.c

diff --git a/ssh.c b/ssh.c
index f3ce6fe0f5f4f3c1d5288df87987418c6e73b079..5d6514b5ae7829509c8001f435517d1e44061c6f 100644 (file)
--- a/ssh.c
+++ b/ssh.c
@@ -3592,9 +3592,11 @@ static int ssh_test_for_upstream(const char *host, int port, Conf *conf)
     int savedport;
     int ret;
 
+    random_ref(); /* platform may need this to determine share socket name */
     ssh_hostport_setup(host, port, conf, &savedhost, &savedport, NULL);
     ret = ssh_share_test_for_upstream(savedhost, savedport, conf);
     sfree(savedhost);
+    random_unref();
 
     return ret;
 }