diff options
author | Tobias Stoeckmann <tobias@cvs.openbsd.org> | 2009-12-20 15:57:27 +0000 |
---|---|---|
committer | Tobias Stoeckmann <tobias@cvs.openbsd.org> | 2009-12-20 15:57:27 +0000 |
commit | a6f46949f164c471ac5e8dbde642a433d32a4148 (patch) | |
tree | 0da871dba6c2c14dad1551ec990fe41a9c842420 | |
parent | 8c28f845a87c788242c1b91b3040a096fd799fd7 (diff) |
Removed lstat, because fstat will do most of the checks later on. Make
sure with open() that we don't follow symbolic links.
With input by and ok millert, ok deraadt
-rw-r--r-- | usr.sbin/popa3d/mailbox.c | 21 |
1 files changed, 3 insertions, 18 deletions
diff --git a/usr.sbin/popa3d/mailbox.c b/usr.sbin/popa3d/mailbox.c index 3a4dcefff01..70968f69de9 100644 --- a/usr.sbin/popa3d/mailbox.c +++ b/usr.sbin/popa3d/mailbox.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mailbox.c,v 1.6 2003/05/12 19:28:22 camield Exp $ */ +/* $OpenBSD: mailbox.c,v 1.7 2009/12/20 15:57:26 tobias Exp $ */ /* * Mailbox access. @@ -336,7 +336,6 @@ static int mailbox_parse(int init) int mailbox_open(char *spool, char *mailbox) { char *pathname; - struct stat stat; int result; mailbox_fd = -1; @@ -344,22 +343,8 @@ int mailbox_open(char *spool, char *mailbox) if (asprintf(&pathname, "%s/%s", spool, mailbox) == -1) return 1; - if (lstat(pathname, &stat)) { - free(pathname); - return errno != ENOENT; - } - - if (!S_ISREG(stat.st_mode)) { - free(pathname); - return 1; - } - - if (!stat.st_size) { - free(pathname); - return 0; - } - - mailbox_fd = open(pathname, O_RDWR | O_NOCTTY | O_NONBLOCK); + mailbox_fd = open(pathname, + O_RDWR | O_NOCTTY | O_NOFOLLOW | O_NONBLOCK); free(pathname); |