summaryrefslogtreecommitdiff
path: root/usr.bin/ssh/login.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1999-09-29 21:14:17 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1999-09-29 21:14:17 +0000
commitbd42b4ae82b68c101d7026b390103e5c550cf0f7 (patch)
tree0668d19f4d9f3b8bdbed84fb6d1b1af73ceb6884 /usr.bin/ssh/login.c
parent3a463f8415ec56ee971fc5118becee2d84a1b915 (diff)
numerous sprintf, strncpy, strcpy cleanups
Diffstat (limited to 'usr.bin/ssh/login.c')
-rw-r--r--usr.bin/ssh/login.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/usr.bin/ssh/login.c b/usr.bin/ssh/login.c
index 5fe7cfccba2..f1e2883f32e 100644
--- a/usr.bin/ssh/login.c
+++ b/usr.bin/ssh/login.c
@@ -18,7 +18,7 @@ on a tty.
*/
#include "includes.h"
-RCSID("$Id: login.c,v 1.2 1999/09/29 18:16:19 dugsong Exp $");
+RCSID("$Id: login.c,v 1.3 1999/09/29 21:14:16 deraadt Exp $");
#ifdef HAVE_LIBUTIL_LOGIN
#include <util.h>
@@ -51,16 +51,19 @@ unsigned long get_last_login_time(uid_t uid, const char *name,
int fd;
#ifdef _PATH_LASTLOG
- sprintf(lastlogfile, "%.200s/%.200s", _PATH_LASTLOG, name);
+ snprintf(lastlogfile, sizeof lastlogfile, "%.200s/%.200s",
+ _PATH_LASTLOG, name);
#else
#ifdef LASTLOG_FILE
- sprintf(lastlogfile, "%.200s/%.200s", LASTLOG_FILE, name);
+ snprintf(lastlogfile, sizeof lastlogfile, "%.200s/%.200s",
+ LASTLOG_FILE, name);
#else
- sprintf(lastlogfile, "%.200s/%.200s", SSH_LASTLOG, name);
+ snprintf(lastlogfile, sizeof lastlogfile, "%.200s/%.200s",
+ SSH_LASTLOG, name);
#endif
#endif
- strcpy(buf, "");
+ buf[0] = '\0';
fd = open(lastlogfile, O_RDONLY);
if (fd < 0)
@@ -108,7 +111,7 @@ unsigned long get_last_login_time(uid_t uid, const char *logname,
#endif
#endif
- strcpy(buf, "");
+ buf[0] = '\0';
fd = open(lastlog, O_RDONLY);
if (fd < 0)
@@ -337,7 +340,8 @@ void record_login(int pid, const char *ttyname, const char *user, uid_t uid,
strncpy(ll.ll_line, ttyname + 5, sizeof(ll.ll_line));
strncpy(ll.ll_host, host, sizeof(ll.ll_host));
#ifdef LASTLOG_IS_DIR
- sprintf(lastlogfile, "%.100s/%.100s", lastlog, user);
+ snprintf(lastlogfile, sizeof lastlogfile, "%.100s/%.100s",
+ lastlog, user);
fd = open(lastlogfile, O_WRONLY | O_CREAT, 0644);
if (fd >= 0)
{