summaryrefslogtreecommitdiff
path: root/auth2.c
diff options
context:
space:
mode:
authormarkus@openbsd.org <markus@openbsd.org>2018-07-09 21:35:50 +0000
committerDamien Miller <djm@mindrot.org>2018-07-10 15:27:43 +1000
commitc7d39ac8dc3587c5f05bdd5bcd098eb5c201c0c8 (patch)
tree28e4a7c9d114a3ab3c7710850e54b1a8c41f840e /auth2.c
parentc3cb7790e9efb14ba74b2d9f543ad593b3d55b31 (diff)
downloadopenssh-git-c7d39ac8dc3587c5f05bdd5bcd098eb5c201c0c8.tar.gz
upstream: sshd: switch authentication to sshbuf API; ok djm@
OpenBSD-Commit-ID: 880aa06bce4b140781e836bb56bec34873290641
Diffstat (limited to 'auth2.c')
-rw-r--r--auth2.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/auth2.c b/auth2.c
index 01c83046..c3ae5605 100644
--- a/auth2.c
+++ b/auth2.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: auth2.c,v 1.147 2018/05/11 03:22:55 dtucker Exp $ */
+/* $OpenBSD: auth2.c,v 1.148 2018/07/09 21:35:50 markus Exp $ */
/*
* Copyright (c) 2000 Markus Friedl. All rights reserved.
*
@@ -41,7 +41,7 @@
#include "ssh2.h"
#include "packet.h"
#include "log.h"
-#include "buffer.h"
+#include "sshbuf.h"
#include "misc.h"
#include "servconf.h"
#include "compat.h"
@@ -451,11 +451,12 @@ auth2_method_allowed(Authctxt *authctxt, const char *method,
static char *
authmethods_get(Authctxt *authctxt)
{
- Buffer b;
+ struct sshbuf *b;
char *list;
- u_int i;
+ int i, r;
- buffer_init(&b);
+ if ((b = sshbuf_new()) == NULL)
+ fatal("%s: sshbuf_new failed", __func__);
for (i = 0; authmethods[i] != NULL; i++) {
if (strcmp(authmethods[i]->name, "none") == 0)
continue;
@@ -465,14 +466,13 @@ authmethods_get(Authctxt *authctxt)
if (!auth2_method_allowed(authctxt, authmethods[i]->name,
NULL))
continue;
- if (buffer_len(&b) > 0)
- buffer_append(&b, ",", 1);
- buffer_append(&b, authmethods[i]->name,
- strlen(authmethods[i]->name));
+ if ((r = sshbuf_putf(b, "%s%s", sshbuf_len(b) ? "," : "",
+ authmethods[i]->name)) != 0)
+ fatal("%s: buffer error: %s", __func__, ssh_err(r));
}
- if ((list = sshbuf_dup_string(&b)) == NULL)
+ if ((list = sshbuf_dup_string(b)) == NULL)
fatal("%s: sshbuf_dup_string failed", __func__);
- buffer_free(&b);
+ sshbuf_free(b);
return list;
}