=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/login/login.c,v retrieving revision 1.66 retrieving revision 1.67 diff -u -r1.66 -r1.67 --- src/usr.bin/login/login.c 2015/12/09 19:26:26 1.66 +++ src/usr.bin/login/login.c 2015/12/26 20:51:35 1.67 @@ -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 @@ 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 @@ 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); } }