mirror of
https://github.com/clearml/dropbear
synced 2025-02-07 13:21:15 +00:00
use a buffer rather than raw char array for creating
the comma-seperated algorithm lists --HG-- extra : convert_revision : bd00bc1e914dc1a816e9a2cca38c7bd3b6865dd0
This commit is contained in:
parent
b332e4aaf9
commit
5a6404712c
@ -209,21 +209,20 @@ int have_algo(char* algo, size_t algolen, algo_type algos[]) {
|
|||||||
/* Output a comma separated list of algorithms to a buffer */
|
/* Output a comma separated list of algorithms to a buffer */
|
||||||
void buf_put_algolist(buffer * buf, algo_type localalgos[]) {
|
void buf_put_algolist(buffer * buf, algo_type localalgos[]) {
|
||||||
|
|
||||||
unsigned int pos = 0, i, len;
|
unsigned int i, len;
|
||||||
char str[50]; /* enough for local algo storage */
|
unsigned int donefirst = 0;
|
||||||
|
buffer *algolist = NULL;
|
||||||
|
|
||||||
|
algolist = buf_new(100);
|
||||||
for (i = 0; localalgos[i].name != NULL; i++) {
|
for (i = 0; localalgos[i].name != NULL; i++) {
|
||||||
if (localalgos[i].usable) {
|
if (localalgos[i].usable) {
|
||||||
/* Avoid generating a trailing comma */
|
if (donefirst)
|
||||||
if (pos)
|
buf_putbyte(algolist, ',');
|
||||||
str[pos++] = ',';
|
donefirst = 1;
|
||||||
len = strlen(localalgos[i].name);
|
len = strlen(localalgos[i].name);
|
||||||
memcpy(&str[pos], localalgos[i].name, len);
|
buf_putbytes(algolist, localalgos[i].name, len);
|
||||||
pos += len;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
str[pos]=0;
|
buf_putstring(buf, algolist->data, algolist->len);
|
||||||
/* Debug this */
|
buf_free(algolist);
|
||||||
TRACE(("buf_put_algolist: %s", str))
|
|
||||||
buf_putstring(buf, str, pos);
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user