diff options
author | Damien Miller <djm@mindrot.org> | 2001-10-22 16:49:22 +1000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2001-10-22 16:49:22 +1000 |
commit | 3a8a5cd5b075c02dac1d802765eec6c1ff5c11d6 (patch) | |
tree | a1ce6882410eb1c5fc1f568ed96500930711d456 /loginrec.c | |
parent | 13aae5ee7673a0b75369256e7ed6117f9f1b6c7d (diff) |
- (djm) Fix fd leak in loginrec.c (ro fd to lastlog was left open).
Report from Michal Zalewski <lcamtuf@coredump.cx>
Diffstat (limited to 'loginrec.c')
-rw-r--r-- | loginrec.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/loginrec.c b/loginrec.c index 140cd3f64..8d0b3b81f 100644 --- a/loginrec.c +++ b/loginrec.c | |||
@@ -163,7 +163,7 @@ | |||
163 | #include "log.h" | 163 | #include "log.h" |
164 | #include "atomicio.h" | 164 | #include "atomicio.h" |
165 | 165 | ||
166 | RCSID("$Id: loginrec.c,v 1.35 2001/10/02 00:29:00 stevesk Exp $"); | 166 | RCSID("$Id: loginrec.c,v 1.36 2001/10/22 06:49:23 djm Exp $"); |
167 | 167 | ||
168 | #ifdef HAVE_UTIL_H | 168 | #ifdef HAVE_UTIL_H |
169 | # include <util.h> | 169 | # include <util.h> |
@@ -1487,17 +1487,20 @@ lastlog_get_entry(struct logininfo *li) | |||
1487 | struct lastlog last; | 1487 | struct lastlog last; |
1488 | int fd; | 1488 | int fd; |
1489 | 1489 | ||
1490 | if (lastlog_openseek(li, &fd, O_RDONLY)) { | 1490 | if (!lastlog_openseek(li, &fd, O_RDONLY)) |
1491 | if (atomicio(read, fd, &last, sizeof(last)) != sizeof(last)) { | 1491 | return 0; |
1492 | log("lastlog_get_entry: Error reading from %s: %s", | 1492 | |
1493 | LASTLOG_FILE, strerror(errno)); | 1493 | if (atomicio(read, fd, &last, sizeof(last)) != sizeof(last)) { |
1494 | return 0; | 1494 | close(fd); |
1495 | } else { | 1495 | log("lastlog_get_entry: Error reading from %s: %s", |
1496 | lastlog_populate_entry(li, &last); | 1496 | LASTLOG_FILE, strerror(errno)); |
1497 | return 1; | ||
1498 | } | ||
1499 | } else { | ||
1500 | return 0; | 1497 | return 0; |
1501 | } | 1498 | } |
1499 | |||
1500 | close(fd); | ||
1501 | |||
1502 | lastlog_populate_entry(li, &last); | ||
1503 | |||
1504 | return 1; | ||
1502 | } | 1505 | } |
1503 | #endif /* USE_LASTLOG */ | 1506 | #endif /* USE_LASTLOG */ |