summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--loginrec.c9
2 files changed, 11 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 16100a052..5007e8c52 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
120110102
2 - (djm) [loginrec.c] Fix some fd leaks on error paths. ok dtucker
3
120101226 420101226
2 - (dtucker) OpenBSD CVS Sync 5 - (dtucker) OpenBSD CVS Sync
3 - djm@cvs.openbsd.org 2010/12/08 04:02:47 6 - djm@cvs.openbsd.org 2010/12/08 04:02:47
diff --git a/loginrec.c b/loginrec.c
index cccaa47ae..587d55f7d 100644
--- a/loginrec.c
+++ b/loginrec.c
@@ -873,11 +873,13 @@ utmp_write_direct(struct logininfo *li, struct utmp *ut)
873 pos = (off_t)tty * sizeof(struct utmp); 873 pos = (off_t)tty * sizeof(struct utmp);
874 if ((ret = lseek(fd, pos, SEEK_SET)) == -1) { 874 if ((ret = lseek(fd, pos, SEEK_SET)) == -1) {
875 logit("%s: lseek: %s", __func__, strerror(errno)); 875 logit("%s: lseek: %s", __func__, strerror(errno));
876 close(fd);
876 return (0); 877 return (0);
877 } 878 }
878 if (ret != pos) { 879 if (ret != pos) {
879 logit("%s: Couldn't seek to tty %d slot in %s", 880 logit("%s: Couldn't seek to tty %d slot in %s",
880 __func__, tty, UTMP_FILE); 881 __func__, tty, UTMP_FILE);
882 close(fd);
881 return (0); 883 return (0);
882 } 884 }
883 /* 885 /*
@@ -893,16 +895,20 @@ utmp_write_direct(struct logininfo *li, struct utmp *ut)
893 895
894 if ((ret = lseek(fd, pos, SEEK_SET)) == -1) { 896 if ((ret = lseek(fd, pos, SEEK_SET)) == -1) {
895 logit("%s: lseek: %s", __func__, strerror(errno)); 897 logit("%s: lseek: %s", __func__, strerror(errno));
898 close(fd);
896 return (0); 899 return (0);
897 } 900 }
898 if (ret != pos) { 901 if (ret != pos) {
899 logit("%s: Couldn't seek to tty %d slot in %s", 902 logit("%s: Couldn't seek to tty %d slot in %s",
900 __func__, tty, UTMP_FILE); 903 __func__, tty, UTMP_FILE);
904 close(fd);
901 return (0); 905 return (0);
902 } 906 }
903 if (atomicio(vwrite, fd, ut, sizeof(*ut)) != sizeof(*ut)) { 907 if (atomicio(vwrite, fd, ut, sizeof(*ut)) != sizeof(*ut)) {
904 logit("%s: error writing %s: %s", __func__, 908 logit("%s: error writing %s: %s", __func__,
905 UTMP_FILE, strerror(errno)); 909 UTMP_FILE, strerror(errno));
910 close(fd);
911 return (0);
906 } 912 }
907 913
908 close(fd); 914 close(fd);
@@ -1206,7 +1212,7 @@ wtmp_get_entry(struct logininfo *li)
1206 close (fd); 1212 close (fd);
1207 return (0); 1213 return (0);
1208 } 1214 }
1209 if ( wtmp_islogin(li, &ut) ) { 1215 if (wtmp_islogin(li, &ut) ) {
1210 found = 1; 1216 found = 1;
1211 /* 1217 /*
1212 * We've already checked for a time in struct 1218 * We've already checked for a time in struct
@@ -1502,6 +1508,7 @@ lastlog_openseek(struct logininfo *li, int *fd, int filemode)
1502 if (lseek(*fd, offset, SEEK_SET) != offset) { 1508 if (lseek(*fd, offset, SEEK_SET) != offset) {
1503 logit("%s: %s->lseek(): %s", __func__, 1509 logit("%s: %s->lseek(): %s", __func__,
1504 lastlog_file, strerror(errno)); 1510 lastlog_file, strerror(errno));
1511 close(*fd);
1505 return (0); 1512 return (0);
1506 } 1513 }
1507 } 1514 }