From 758ac4c206e35872a9c520356494f0f6c7477831 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sat, 24 Oct 2015 16:44:37 +0100 Subject: [PATCH] Initialise the random state in ssh_test_for_upstream(). 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 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ssh.c b/ssh.c index f3ce6fe0..5d6514b5 100644 --- 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; }