summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/finger/util.c15
-rw-r--r--usr.bin/login/login.c13
-rw-r--r--usr.bin/ssh/sshlogin.c6
3 files changed, 16 insertions, 18 deletions
diff --git a/usr.bin/finger/util.c b/usr.bin/finger/util.c
index 0a1ba56a721..380c06682aa 100644
--- a/usr.bin/finger/util.c
+++ b/usr.bin/finger/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.31 2015/08/20 22:32:41 deraadt Exp $ */
+/* $OpenBSD: util.c,v 1.32 2015/12/26 20:51:35 guenther Exp $ */
/*
* Copyright (c) 1989 The Regents of the University of California.
@@ -196,13 +196,12 @@ enter_lastlog(PERSON *pn)
opened = 1;
}
if (fd == -1 ||
- lseek(fd, (off_t)(pn->uid * sizeof(ll)), SEEK_SET) !=
- (long)(pn->uid * sizeof(ll)) ||
- read(fd, (char *)&ll, sizeof(ll)) != sizeof(ll)) {
- /* as if never logged in */
- ll.ll_line[0] = ll.ll_host[0] = '\0';
- ll.ll_time = 0;
- }
+ pread(fd, &ll, sizeof(ll), (off_t)pn->uid * sizeof(ll)) !=
+ sizeof(ll)) {
+ /* as if never logged in */
+ ll.ll_line[0] = ll.ll_host[0] = '\0';
+ ll.ll_time = 0;
+ }
if ((w = pn->whead) == NULL)
doit = 1;
else if (ll.ll_time != 0) {
diff --git a/usr.bin/login/login.c b/usr.bin/login/login.c
index 3bea8919225..48bb2ce450d 100644
--- a/usr.bin/login/login.c
+++ b/usr.bin/login/login.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: login.c,v 1.66 2015/12/09 19:26:26 mmcc Exp $ */
+/* $OpenBSD: login.c,v 1.67 2015/12/26 20:51:35 guenther Exp $ */
/* $NetBSD: login.c,v 1.13 1996/05/15 23:50:16 jtc Exp $ */
/*-
@@ -839,12 +839,13 @@ void
dolastlog(int quiet)
{
struct lastlog ll;
+ off_t pos;
int fd;
if ((fd = open(_PATH_LASTLOG, O_RDWR, 0)) >= 0) {
- (void)lseek(fd, (off_t)pwd->pw_uid * sizeof(ll), SEEK_SET);
+ pos = (off_t)pwd->pw_uid * sizeof(ll);
if (!quiet) {
- if (read(fd, (char *)&ll, sizeof(ll)) == sizeof(ll) &&
+ if (pread(fd, &ll, sizeof(ll), pos) == sizeof(ll) &&
ll.ll_time != 0) {
(void)printf("Last login: %.*s ",
24-5, (char *)ctime(&ll.ll_time));
@@ -857,15 +858,13 @@ dolastlog(int quiet)
ll.ll_host);
(void)putchar('\n');
}
- (void)lseek(fd, (off_t)pwd->pw_uid * sizeof(ll),
- SEEK_SET);
}
- memset((void *)&ll, 0, sizeof(ll));
+ memset(&ll, 0, sizeof(ll));
(void)time(&ll.ll_time);
(void)strncpy(ll.ll_line, tty, sizeof(ll.ll_line));
if (hostname)
(void)strncpy(ll.ll_host, hostname, sizeof(ll.ll_host));
- (void)write(fd, (char *)&ll, sizeof(ll));
+ (void)pwrite(fd, &ll, sizeof(ll), pos);
(void)close(fd);
}
}
diff --git a/usr.bin/ssh/sshlogin.c b/usr.bin/ssh/sshlogin.c
index cd21b2e2c2a..a9c7cc91ef9 100644
--- a/usr.bin/ssh/sshlogin.c
+++ b/usr.bin/ssh/sshlogin.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sshlogin.c,v 1.31 2015/01/20 23:14:00 deraadt Exp $ */
+/* $OpenBSD: sshlogin.c,v 1.32 2015/12/26 20:51:35 guenther Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -83,7 +83,7 @@ get_last_login_time(uid_t uid, const char *logname,
if (fd < 0)
return 0;
- pos = (long) uid * sizeof(ll);
+ pos = (off_t)uid * sizeof(ll);
r = lseek(fd, pos, SEEK_SET);
if (r == -1) {
error("%s: lseek: %s", __func__, strerror(errno));
@@ -176,7 +176,7 @@ record_login(pid_t pid, const char *tty, const char *user, uid_t uid,
strncpy(ll.ll_host, host, sizeof(ll.ll_host));
fd = open(lastlog, O_RDWR);
if (fd >= 0) {
- lseek(fd, (off_t) ((long) uid * sizeof(ll)), SEEK_SET);
+ lseek(fd, (off_t)uid * sizeof(ll), SEEK_SET);
if (write(fd, &ll, sizeof(ll)) != sizeof(ll))
logit("Could not write %.100s: %.100s", lastlog, strerror(errno));
close(fd);