diff options
author | Damien Miller <djm@cvs.openbsd.org> | 2004-08-11 11:59:23 +0000 |
---|---|---|
committer | Damien Miller <djm@cvs.openbsd.org> | 2004-08-11 11:59:23 +0000 |
commit | 4a55a77736bd11a46a538ea3842dc93ece05ea82 (patch) | |
tree | 9da0cf8b516a03319982240d19e6f792a2760349 /usr.bin/ssh | |
parent | 45ab9110bca28bbce60ee7b7dbef43d2b31996db (diff) |
check that lseek went were we told it to; ok markus@
Diffstat (limited to 'usr.bin/ssh')
-rw-r--r-- | usr.bin/ssh/sshlogin.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/usr.bin/ssh/sshlogin.c b/usr.bin/ssh/sshlogin.c index ae6f65270b2..78a346eab4c 100644 --- a/usr.bin/ssh/sshlogin.c +++ b/usr.bin/ssh/sshlogin.c @@ -39,7 +39,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: sshlogin.c,v 1.10 2004/07/17 05:31:41 dtucker Exp $"); +RCSID("$OpenBSD: sshlogin.c,v 1.11 2004/08/11 11:59:22 djm Exp $"); #include <util.h> #include <utmp.h> @@ -63,6 +63,7 @@ get_last_login_time(uid_t uid, const char *logname, struct lastlog ll; char *lastlog; int fd; + off_t pos, r; lastlog = _PATH_LASTLOG; buf[0] = '\0'; @@ -70,7 +71,17 @@ get_last_login_time(uid_t uid, const char *logname, fd = open(lastlog, O_RDONLY); if (fd < 0) return 0; - lseek(fd, (off_t) ((long) uid * sizeof(ll)), SEEK_SET); + + pos = (long) uid * sizeof(ll); + r = lseek(fd, pos, SEEK_SET); + if (r == -1) { + error("%s: llseek: %s", __func__, strerror(errno)); + return (0); + } + if (r != pos) { + debug("%s: truncated lastlog", __func__); + return (0); + } if (read(fd, &ll, sizeof(ll)) != sizeof(ll)) { close(fd); return 0; |