mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-02-03 21:52:24 +00:00
Rework keylist_update() to fix both a buffer-size limitation and a
memory leak. [originally from svn r9955]
This commit is contained in:
parent
da052d88f8
commit
13667de106
@ -353,28 +353,27 @@ static void keylist_update(void)
|
|||||||
0, (LPARAM) listentry);
|
0, (LPARAM) listentry);
|
||||||
}
|
}
|
||||||
for (i = 0; NULL != (skey = index234(ssh2keys, i)); i++) {
|
for (i = 0; NULL != (skey = index234(ssh2keys, i)); i++) {
|
||||||
char listentry[512], *p;
|
char *listentry, *p;
|
||||||
int len;
|
int fp_len;
|
||||||
/*
|
/*
|
||||||
* Replace two spaces in the fingerprint with tabs, for
|
* Replace two spaces in the fingerprint with tabs, for
|
||||||
* nice alignment in the box.
|
* nice alignment in the box.
|
||||||
*/
|
*/
|
||||||
p = skey->alg->fingerprint(skey->data);
|
p = skey->alg->fingerprint(skey->data);
|
||||||
strncpy(listentry, p, sizeof(listentry));
|
listentry = dupprintf("%s\t%s", p, skey->comment);
|
||||||
|
fp_len = strlen(listentry);
|
||||||
|
sfree(p);
|
||||||
|
|
||||||
p = strchr(listentry, ' ');
|
p = strchr(listentry, ' ');
|
||||||
if (p)
|
if (p && p < listentry + fp_len)
|
||||||
*p = '\t';
|
*p = '\t';
|
||||||
p = strchr(listentry, ' ');
|
p = strchr(listentry, ' ');
|
||||||
if (p)
|
if (p && p < listentry + fp_len)
|
||||||
*p = '\t';
|
*p = '\t';
|
||||||
len = strlen(listentry);
|
|
||||||
if (len < sizeof(listentry) - 2) {
|
|
||||||
listentry[len] = '\t';
|
|
||||||
strncpy(listentry + len + 1, skey->comment,
|
|
||||||
sizeof(listentry) - len - 1);
|
|
||||||
}
|
|
||||||
SendDlgItemMessage(keylist, 100, LB_ADDSTRING, 0,
|
SendDlgItemMessage(keylist, 100, LB_ADDSTRING, 0,
|
||||||
(LPARAM) listentry);
|
(LPARAM) listentry);
|
||||||
|
sfree(listentry);
|
||||||
}
|
}
|
||||||
SendDlgItemMessage(keylist, 100, LB_SETCURSEL, (WPARAM) - 1, 0);
|
SendDlgItemMessage(keylist, 100, LB_SETCURSEL, (WPARAM) - 1, 0);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user