]> andersk Git - openssh.git/blobdiff - loginrec.c
- (djm) Fix fd leak in loginrec.c (ro fd to lastlog was left open).
[openssh.git] / loginrec.c
index e1e9ce894127ef2eb08e21463afca3bc84e901f6..5e9f96fbd31a1eb473a819a1c5ec443e2e0e8774 100644 (file)
@@ -1487,17 +1487,20 @@ lastlog_get_entry(struct logininfo *li)
        struct lastlog last;
        int fd;
 
-       if (lastlog_openseek(li, &fd, O_RDONLY)) {
-               if (atomicio(read, fd, &last, sizeof(last)) != sizeof(last)) {
-                       log("lastlog_get_entry: Error reading from %s: %s",
-                           LASTLOG_FILE, strerror(errno));
-                       return 0;
-               } else {
-                       lastlog_populate_entry(li, &last);
-                       return 1;
-               }
-       } else {
+       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;
        }
+
+       close(fd);
+
+       lastlog_populate_entry(li, &last);
+
+       return 1;
 }
 #endif /* USE_LASTLOG */
This page took 1.279569 seconds and 4 git commands to generate.