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.
This commit is contained in:
Simon Tatham 2015-10-24 16:44:37 +01:00
Родитель 48eafd66aa
Коммит 758ac4c206
1 изменённых файлов: 2 добавлений и 0 удалений

2
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;
}