diff options
author | Damien Miller <djm@mindrot.org> | 2002-01-22 13:26:38 +0100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2002-01-22 13:26:38 +0100 |
commit | 0e3b87279c3f20630e616b4de1be7cae815682dd (patch) | |
tree | 171bd0872677cd0938cb223fe7c7fbf69fdd6e15 /auth2.c | |
parent | - provos@cvs.openbsd.org 2002/01/13 17:27:07 (diff) | |
download | openssh-0e3b87279c3f20630e616b4de1be7cae815682dd.tar.xz openssh-0e3b87279c3f20630e616b4de1be7cae815682dd.zip |
- markus@cvs.openbsd.org 2002/01/13 17:57:37
[auth2.c auth2-chall.c compat.c sshconnect2.c sshd.c]
use buffer API and avoid static strings of fixed size; ok provos@/mouring@
Diffstat (limited to 'auth2.c')
-rw-r--r-- | auth2.c | 27 |
1 files changed, 9 insertions, 18 deletions
@@ -23,7 +23,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: auth2.c,v 1.81 2002/01/11 13:39:36 markus Exp $"); +RCSID("$OpenBSD: auth2.c,v 1.82 2002/01/13 17:57:37 markus Exp $"); #include <openssl/evp.h> @@ -588,31 +588,22 @@ static char * authmethods_get(void) { Authmethod *method = NULL; - u_int size = 0; + Buffer b; char *list; + buffer_init(&b); for (method = authmethods; method->name != NULL; method++) { if (strcmp(method->name, "none") == 0) continue; if (method->enabled != NULL && *(method->enabled) != 0) { - if (size != 0) - size += strlen(DELIM); - size += strlen(method->name); - } - } - size++; /* trailing '\0' */ - list = xmalloc(size); - list[0] = '\0'; - - for (method = authmethods; method->name != NULL; method++) { - if (strcmp(method->name, "none") == 0) - continue; - if (method->enabled != NULL && *(method->enabled) != 0) { - if (list[0] != '\0') - strlcat(list, DELIM, size); - strlcat(list, method->name, size); + if (buffer_len(&b) > 0) + buffer_append(&b, ",", 1); + buffer_append(&b, method->name, strlen(method->name)); } } + buffer_append(&b, "\0", 1); + list = xstrdup(buffer_ptr(&b)); + buffer_free(&b); return list; } |