summaryrefslogtreecommitdiff
path: root/auth-passwd.c
diff options
context:
space:
mode:
authormarkus@openbsd.org <markus@openbsd.org>2018-07-09 21:26:02 +0000
committerDamien Miller <djm@mindrot.org>2018-07-10 15:21:58 +1000
commit2808d18ca47ad3d251836c555f0e22aaca03d15c (patch)
tree06bc9605dd843d77ee25187637e348369e59cb1d /auth-passwd.c
parent89dd615b8b531979be63f05f9d5624367c9b28e6 (diff)
downloadopenssh-git-2808d18ca47ad3d251836c555f0e22aaca03d15c.tar.gz
upstream: sshd: switch loginmsg to sshbuf API; ok djm@
OpenBSD-Commit-ID: f3cb4e54bff15c593602d95cc43e32ee1a4bac42
Diffstat (limited to 'auth-passwd.c')
-rw-r--r--auth-passwd.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/auth-passwd.c b/auth-passwd.c
index 6097fdd2..65f52518 100644
--- a/auth-passwd.c
+++ b/auth-passwd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: auth-passwd.c,v 1.46 2018/03/03 03:15:51 djm Exp $ */
+/* $OpenBSD: auth-passwd.c,v 1.47 2018/07/09 21:26:02 markus Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -46,16 +46,17 @@
#include <stdarg.h>
#include "packet.h"
-#include "buffer.h"
+#include "sshbuf.h"
+#include "ssherr.h"
#include "log.h"
#include "misc.h"
#include "servconf.h"
-#include "key.h"
+#include "sshkey.h"
#include "hostfile.h"
#include "auth.h"
#include "auth-options.h"
-extern Buffer loginmsg;
+extern struct sshbuf *loginmsg;
extern ServerOptions options;
#ifdef HAVE_LOGIN_CAP
@@ -131,7 +132,7 @@ auth_password(struct ssh *ssh, const char *password)
static void
warn_expiry(Authctxt *authctxt, auth_session_t *as)
{
- char buf[256];
+ int r;
quad_t pwtimeleft, actimeleft, daysleft, pwwarntime, acwarntime;
pwwarntime = acwarntime = TWO_WEEKS;
@@ -148,17 +149,17 @@ warn_expiry(Authctxt *authctxt, auth_session_t *as)
#endif
if (pwtimeleft != 0 && pwtimeleft < pwwarntime) {
daysleft = pwtimeleft / DAY + 1;
- snprintf(buf, sizeof(buf),
+ if ((r = sshbuf_putf(loginmsg,
"Your password will expire in %lld day%s.\n",
- daysleft, daysleft == 1 ? "" : "s");
- buffer_append(&loginmsg, buf, strlen(buf));
+ daysleft, daysleft == 1 ? "" : "s")) != 0)
+ fatal("%s: buffer error: %s", __func__, ssh_err(r));
}
if (actimeleft != 0 && actimeleft < acwarntime) {
daysleft = actimeleft / DAY + 1;
- snprintf(buf, sizeof(buf),
+ if ((r = sshbuf_putf(loginmsg,
"Your account will expire in %lld day%s.\n",
- daysleft, daysleft == 1 ? "" : "s");
- buffer_append(&loginmsg, buf, strlen(buf));
+ daysleft, daysleft == 1 ? "" : "s")) != 0)
+ fatal("%s: buffer error: %s", __func__, ssh_err(r));
}
}