summaryrefslogtreecommitdiff
path: root/auth2-passwd.c
diff options
context:
space:
mode:
authorAlistair Delva <adelva@google.com>2020-08-21 00:00:13 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2020-08-21 00:00:13 +0000
commited358b3546c776c1c677fd88eb8f716cf6187510 (patch)
tree3c6134bcb2cda4b9dccc57b4a8b997a945aab62d /auth2-passwd.c
parent22246b08952d746a7cc5a292570636cf4277598f (diff)
parent44a1065de8a58c51a021243a28bfa01e87822e4f (diff)
Merge changes I934c73d4,I28cdc9a0,I9e734da9,I3c079d86
* changes: UPSTREAM: depend UPSTREAM: upstream: avoid possible NULL deref; from Pedro Martelletto Revert "upstream: fix compilation with DEBUG_KEXDH; bz#3160 ok dtucker@" Merge upstream-master into master
Diffstat (limited to 'auth2-passwd.c')
-rw-r--r--auth2-passwd.c38
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;
}