diff options
Diffstat (limited to 'auth2-passwd.c')
-rw-r--r-- | auth2-passwd.c | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/auth2-passwd.c b/auth2-passwd.c index 09cf077c..2d0b2af2 100644 --- a/auth2-passwd.c +++ b/auth2-passwd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auth2-passwd.c,v 1.12 2014/07/15 15:54:14 millert Exp $ */ +/* $OpenBSD: auth2-passwd.c,v 1.18 2020/02/26 13:40:09 jsg Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * @@ -27,16 +27,17 @@ #include <sys/types.h> +#include <stdlib.h> #include <string.h> #include <stdarg.h> +#include <stdio.h> -#include "xmalloc.h" #include "packet.h" +#include "ssherr.h" #include "log.h" -#include "key.h" +#include "sshkey.h" #include "hostfile.h" #include "auth.h" -#include "buffer.h" #ifdef GSSAPI #include "ssh-gss.h" #endif @@ -48,32 +49,27 @@ extern ServerOptions options; static int -userauth_passwd(Authctxt *authctxt) +userauth_passwd(struct ssh *ssh) { - char *password, *newpass; - int authenticated = 0; - int change; - u_int len, newlen; + char *password; + int authenticated = 0, r; + u_char change; + size_t len; - change = packet_get_char(); - password = packet_get_string(&len); - if (change) { - /* discard new password from packet */ - newpass = packet_get_string(&newlen); - explicit_bzero(newpass, newlen); - free(newpass); - } - packet_check_eom(); + if ((r = sshpkt_get_u8(ssh, &change)) != 0 || + (r = sshpkt_get_cstring(ssh, &password, &len)) != 0 || + (change && (r = sshpkt_get_cstring(ssh, NULL, NULL)) != 0) || + (r = sshpkt_get_end(ssh)) != 0) + fatal("%s: %s", __func__, ssh_err(r)); if (change) logit("password change not supported"); #if !defined(ANDROID) /* no password authentication in Android */ - else if (PRIVSEP(auth_password(authctxt, password)) == 1) + else if (PRIVSEP(auth_password(ssh, password)) == 1) authenticated = 1; #endif - explicit_bzero(password, len); - free(password); + freezero(password, len); return authenticated; } |