diff options
author | djm <djm> | 2003-01-07 05:46:58 +0000 |
---|---|---|
committer | djm <djm> | 2003-01-07 05:46:58 +0000 |
commit | 8ed7607abf3cfe4a2df3f1e9d6b3672866943f22 (patch) | |
tree | db342b9433e526efeeccad2ca59d6b1d77a4e095 /loginrec.c | |
parent | 49b87b89fc6d151d59d91cca5d9aa4886398b717 (diff) | |
download | openssh-8ed7607abf3cfe4a2df3f1e9d6b3672866943f22.tar.gz |
- (djm) Bug #110: bogus error messages in lastlog_get_entry(). Fix based
on one by peak@argo.troja.mff.cuni.cz
Diffstat (limited to 'loginrec.c')
-rw-r--r-- | loginrec.c | 34 |
1 files changed, 22 insertions, 12 deletions
@@ -163,7 +163,7 @@ #include "log.h" #include "atomicio.h" -RCSID("$Id: loginrec.c,v 1.45 2003/01/03 03:42:28 djm Exp $"); +RCSID("$Id: loginrec.c,v 1.46 2003/01/07 05:46:58 djm Exp $"); #ifdef HAVE_UTIL_H # include <util.h> @@ -1522,22 +1522,32 @@ int lastlog_get_entry(struct logininfo *li) { struct lastlog last; - int fd; + int fd, ret; if (!lastlog_openseek(li, &fd, O_RDONLY)) - return 0; - - if (atomicio(read, fd, &last, sizeof(last)) != sizeof(last)) { - close(fd); - log("lastlog_get_entry: Error reading from %s: %s", - LASTLOG_FILE, strerror(errno)); - return 0; - } + return (0); + ret = atomicio(read, fd, &last, sizeof(last)); close(fd); - lastlog_populate_entry(li, &last); + switch (ret) { + case 0: + memset(&last, '\0', sizeof(last)); + /* FALLTHRU */ + case sizeof(last): + lastlog_populate_entry(li, &last); + return (1); + case -1: + error("%s: Error reading from %s: %s", __func__, + LASTLOG_FILE, strerror(errno)); + return (0); + default: + error("%s: Error reading from %s: Expecting %d, got %d", + __func__, LASTLOG_FILE, sizeof(last), ret); + return (0); + } - return 1; + /* NOTREACHED */ + return (0); } #endif /* USE_LASTLOG */ |