1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-10 01:48:00 +00:00

Fix assertion failure in host keys log message.

When Jacob introduced this message in d0d3c47a0, he was right to
assume that hostkey_algs[] and ssh->uncert_hostkeys[] were sorted in
the same order. Unfortunately, he became wrong less than an hour later
when I committed d06098622. Now we avoid making any such assumption.
This commit is contained in:
Simon Tatham 2016-03-27 14:59:18 +01:00
parent a8d466c0ea
commit 909a7af07c

17
ssh.c
View File

@ -7256,12 +7256,17 @@ static void do_ssh2_transport(Ssh ssh, const void *vin, int inlen,
* Make a note of any other host key formats that are available.
*/
{
int i, j = 0;
int i, j;
char *list = NULL;
for (i = 0; i < lenof(hostkey_algs); i++) {
if (hostkey_algs[i].alg == ssh->hostkey)
continue;
else if (ssh->uncert_hostkeys[j] == i) {
for (j = 0; j < ssh->n_uncert_hostkeys; j++)
if (ssh->uncert_hostkeys[j] == i)
break;
if (j < ssh->n_uncert_hostkeys) {
char *newlist;
if (list)
newlist = dupprintf("%s/%s", list,
@ -7270,14 +7275,6 @@ static void do_ssh2_transport(Ssh ssh, const void *vin, int inlen,
newlist = dupprintf("%s", hostkey_algs[i].alg->name);
sfree(list);
list = newlist;
j++;
/* Assumes that hostkey_algs and uncert_hostkeys are
* sorted in the same order */
if (j == ssh->n_uncert_hostkeys)
break;
else
assert(ssh->uncert_hostkeys[j] >
ssh->uncert_hostkeys[j-1]);
}
}
if (list) {