summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2015-12-26 20:51:36 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2015-12-26 20:51:36 +0000
commitfc82a112e1324ecfb4c476b6f72af776c5825830 (patch)
tree3685c09f8fc1730b4920d0e11531ceb075e97c9a /usr.sbin
parent2b912f2c038f2bea4acbdae6914cd1ae664e8457 (diff)
Use pread/pwrite instead separate lseek+read/write for lastlog.
Cast to off_t before multiplication to avoid truncation on ILP32 ok kettenis@ mmcc@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pppd/auth.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/usr.sbin/pppd/auth.c b/usr.sbin/pppd/auth.c
index 286bb49fbcf..df1c5deb9bc 100644
--- a/usr.sbin/pppd/auth.c
+++ b/usr.sbin/pppd/auth.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: auth.c,v 1.34 2015/01/16 06:40:19 deraadt Exp $ */
+/* $OpenBSD: auth.c,v 1.35 2015/12/26 20:51:35 guenther Exp $ */
/*
* auth.c - PPP authentication and phase control.
@@ -930,12 +930,12 @@ plogin(user, passwd, msg, msglen)
struct lastlog ll;
int fd;
- if ((fd = open(_PATH_LASTLOG, O_RDWR, 0)) >= 0) {
- (void)lseek(fd, (off_t)(pw->pw_uid * sizeof(ll)), SEEK_SET);
- memset((void *)&ll, 0, sizeof(ll));
+ if ((fd = open(_PATH_LASTLOG, O_RDWR)) >= 0) {
+ memset(&ll, 0, sizeof(ll));
(void)time(&ll.ll_time);
(void)strncpy(ll.ll_line, tty, sizeof(ll.ll_line));
- (void)write(fd, (char *)&ll, sizeof(ll));
+ (void)pwrite(fd, &ll, sizeof(ll), (off_t)pw->pw_uid *
+ sizeof(ll));
(void)close(fd);
}
}