diff options
author | markus@openbsd.org <markus@openbsd.org> | 2018-07-09 21:26:02 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2018-07-10 15:21:58 +1000 |
commit | 2808d18ca47ad3d251836c555f0e22aaca03d15c (patch) | |
tree | 06bc9605dd843d77ee25187637e348369e59cb1d /sshlogin.c | |
parent | 89dd615b8b531979be63f05f9d5624367c9b28e6 (diff) | |
download | openssh-git-2808d18ca47ad3d251836c555f0e22aaca03d15c.tar.gz |
upstream: sshd: switch loginmsg to sshbuf API; ok djm@
OpenBSD-Commit-ID: f3cb4e54bff15c593602d95cc43e32ee1a4bac42
Diffstat (limited to 'sshlogin.c')
-rw-r--r-- | sshlogin.c | 22 |
1 files changed, 14 insertions, 8 deletions
@@ -1,4 +1,4 @@ -/* $OpenBSD: sshlogin.c,v 1.32 2015/12/26 20:51:35 guenther Exp $ */ +/* $OpenBSD: sshlogin.c,v 1.33 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 @@ -55,13 +55,15 @@ #include <unistd.h> #include <limits.h> +#include "sshlogin.h" +#include "ssherr.h" #include "loginrec.h" #include "log.h" -#include "buffer.h" +#include "sshbuf.h" #include "misc.h" #include "servconf.h" -extern Buffer loginmsg; +extern struct sshbuf *loginmsg; extern ServerOptions options; /* @@ -88,8 +90,9 @@ static void store_lastlog_message(const char *user, uid_t uid) { #ifndef NO_SSH_LASTLOG - char *time_string, hostname[HOST_NAME_MAX+1] = "", buf[512]; + char *time_string, hostname[HOST_NAME_MAX+1] = ""; time_t last_login_time; + int r; if (!options.print_lastlog) return; @@ -97,7 +100,9 @@ store_lastlog_message(const char *user, uid_t uid) # ifdef CUSTOM_SYS_AUTH_GET_LASTLOGIN_MSG time_string = sys_auth_get_lastlogin_msg(user, uid); if (time_string != NULL) { - buffer_append(&loginmsg, time_string, strlen(time_string)); + if ((r = sshbuf_put(loginmsg, + time_string, strlen(time_string))) != 0) + fatal("%s: buffer error: %s", __func__, ssh_err(r)); free(time_string); } # else @@ -108,12 +113,13 @@ store_lastlog_message(const char *user, uid_t uid) time_string = ctime(&last_login_time); time_string[strcspn(time_string, "\n")] = '\0'; if (strcmp(hostname, "") == 0) - snprintf(buf, sizeof(buf), "Last login: %s\r\n", + r = sshbuf_putf(loginmsg, "Last login: %s\r\n", time_string); else - snprintf(buf, sizeof(buf), "Last login: %s from %s\r\n", + r = sshbuf_putf(loginmsg, "Last login: %s from %s\r\n", time_string, hostname); - buffer_append(&loginmsg, buf, strlen(buf)); + if (r != 0) + fatal("%s: buffer error: %s", __func__, ssh_err(r)); } # endif /* CUSTOM_SYS_AUTH_GET_LASTLOGIN_MSG */ #endif /* NO_SSH_LASTLOG */ |