blob: 0c16d9d1a0e34cda87fcb315b0e10e5450f19aed (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#include "ssh_crypto_common.h"
#include <string.h>
/* We need the first algorithm in the client side,
so search l first
*/
int
search_name(name_list l, const char *s)
{
size_t ns = 1;
size_t i,j;
const char *p;
if (*s=='\0')
return -1;
for (p=s; *p; p++) {
if (*p==',') ns++;
}
const char *start[ns], *end[ns];
p = s;
for (i=0; i<ns; i++) {
start[i] = p;
end[i] = strchr(p, ',');
p = end[i]+1;
}
end[ns-1] = start[ns-1]+strlen(start[ns-1]);
for (i=0; l[i].name!=NULL; i++) {
size_t len = strlen(l[i].name);
for (j=0; j<ns; j++) {
if (start[j]+len==end[j] && strncmp(start[j],l[i].name,len)==0)
return i;
}
}
return -1;
}
|