summaryrefslogtreecommitdiff
path: root/libexec/ld.so/dir.c
diff options
context:
space:
mode:
Diffstat (limited to 'libexec/ld.so/dir.c')
-rw-r--r--libexec/ld.so/dir.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/libexec/ld.so/dir.c b/libexec/ld.so/dir.c
index 7b1e220a2e7..e2edde67e68 100644
--- a/libexec/ld.so/dir.c
+++ b/libexec/ld.so/dir.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dir.c,v 1.20 2014/07/06 18:26:58 otto Exp $ */
+/* $OpenBSD: dir.c,v 1.21 2014/07/09 11:19:42 guenther Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
@@ -43,11 +43,11 @@
#include "dir.h"
struct _dl_dirdesc {
- int dd_fd; /* file descriptor associated with directory */
long dd_loc; /* offset in current buffer */
long dd_size; /* amount of data returned by getdents() */
char *dd_buf; /* data buffer */
int dd_len; /* size of data buffer */
+ int dd_fd; /* file descriptor associated with directory */
};
/*
@@ -60,14 +60,9 @@ _dl_opendir(const char *name)
int fd;
struct stat sb;
- if ((fd = _dl_open(name, O_RDONLY | O_NONBLOCK)) < 0)
+ if ((fd = _dl_open(name, O_RDONLY | O_DIRECTORY | O_CLOEXEC)) < 0)
return (NULL);
- if (_dl_fstat(fd, &sb) || !S_ISDIR(sb.st_mode)) {
- _dl_close(fd);
- return (NULL);
- }
- if (_dl_fcntl(fd, F_SETFD, FD_CLOEXEC) < 0 ||
- (dirp = _dl_malloc(sizeof(*dirp))) == NULL) {
+ if (_dl_fstat(fd, &sb) || (dirp = _dl_malloc(sizeof(*dirp))) == NULL) {
_dl_close(fd);
return (NULL);
}