diff options
author | 2014-07-09 11:19:42 +0000 | |
---|---|---|
committer | 2014-07-09 11:19:42 +0000 | |
commit | 035184975d4f40c860e3b092ec84da1d7a2d9d4a (patch) | |
tree | 45d67d722b32a71c54848b00284628fccd2658b1 | |
parent | cast ASN1_STRING (unsigned char *) to match strlcat's argument (char *) (diff) | |
download | wireguard-openbsd-035184975d4f40c860e3b092ec84da1d7a2d9d4a.tar.xz wireguard-openbsd-035184975d4f40c860e3b092ec84da1d7a2d9d4a.zip |
Resync _dl_opendir() with libc: use O_CLOEXEC and O_DIRECTORY instead
of post-open tests and fixups. Also, reorder _dl_dirdesc to save
8 bytes on LP64.
ok otto@ miod@
-rw-r--r-- | libexec/ld.so/dir.c | 13 |
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); } |