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)
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 01c830467..c3ae56051 100644
--- a/auth2.c
+++ b/auth2.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: auth2.c,v 1.147 2018/05/11 03:22:55 dtucker Exp $ */ 1/* $OpenBSD: auth2.c,v 1.148 2018/07/09 21:35:50 markus Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 * 4 *
@@ -41,7 +41,7 @@
41#include "ssh2.h" 41#include "ssh2.h"
42#include "packet.h" 42#include "packet.h"
43#include "log.h" 43#include "log.h"
44#include "buffer.h" 44#include "sshbuf.h"
45#include "misc.h" 45#include "misc.h"
46#include "servconf.h" 46#include "servconf.h"
47#include "compat.h" 47#include "compat.h"
@@ -451,11 +451,12 @@ auth2_method_allowed(Authctxt *authctxt, const char *method,
451static char * 451static char *
452authmethods_get(Authctxt *authctxt) 452authmethods_get(Authctxt *authctxt)
453{ 453{
454 Buffer b; 454 struct sshbuf *b;
455 char *list; 455 char *list;
456 u_int i; 456 int i, r;
457 457
458 buffer_init(&b); 458 if ((b = sshbuf_new()) == NULL)
459 fatal("%s: sshbuf_new failed", __func__);
459 for (i = 0; authmethods[i] != NULL; i++) { 460 for (i = 0; authmethods[i] != NULL; i++) {
460 if (strcmp(authmethods[i]->name, "none") == 0) 461 if (strcmp(authmethods[i]->name, "none") == 0)
461 continue; 462 continue;
@@ -465,14 +466,13 @@ authmethods_get(Authctxt *authctxt)
465 if (!auth2_method_allowed(authctxt, authmethods[i]->name, 466 if (!auth2_method_allowed(authctxt, authmethods[i]->name,
466 NULL)) 467 NULL))
467 continue; 468 continue;
468 if (buffer_len(&b) > 0) 469 if ((r = sshbuf_putf(b, "%s%s", sshbuf_len(b) ? "," : "",
469 buffer_append(&b, ",", 1); 470 authmethods[i]->name)) != 0)
470 buffer_append(&b, authmethods[i]->name, 471 fatal("%s: buffer error: %s", __func__, ssh_err(r));
471 strlen(authmethods[i]->name));
472 } 472 }
473 if ((list = sshbuf_dup_string(&b)) == NULL) 473 if ((list = sshbuf_dup_string(b)) == NULL)
474 fatal("%s: sshbuf_dup_string failed", __func__); 474 fatal("%s: sshbuf_dup_string failed", __func__);
475 buffer_free(&b); 475 sshbuf_free(b);
476 return list; 476 return list;
477} 477}
478 478