summaryrefslogtreecommitdiff
path: root/lib/libc/gen/opendir.c
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2005-03-01 13:51:48 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2005-03-01 13:51:48 +0000
commiteb23a4e872f9a0d0ecc71f5b0d50babcfd73f29d (patch)
tree144a6eb0a3733344ccdd933b9697ef0439d71c77 /lib/libc/gen/opendir.c
parentb889ed1331009b00b82c11cc7bc7276586bbd332 (diff)
Set errno right before return(), so that it does not risk being reset
by any other functions we will invoke in-between. Fix from Andrey Matveev <andrushock@korovino.net>
Diffstat (limited to 'lib/libc/gen/opendir.c')
-rw-r--r--lib/libc/gen/opendir.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/libc/gen/opendir.c b/lib/libc/gen/opendir.c
index b8d0d3e5c92..bc09745f2cc 100644
--- a/lib/libc/gen/opendir.c
+++ b/lib/libc/gen/opendir.c
@@ -28,7 +28,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: opendir.c,v 1.10 2004/05/18 02:05:52 jfb Exp $";
+static char rcsid[] = "$OpenBSD: opendir.c,v 1.11 2005/03/01 13:51:47 miod Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@@ -82,8 +82,8 @@ __opendir2(const char *name, int flags)
if ((fd = open(name, O_RDONLY | O_NONBLOCK)) == -1)
return (NULL);
if (fstat(fd, &sb) || !S_ISDIR(sb.st_mode)) {
- errno = ENOTDIR;
close(fd);
+ errno = ENOTDIR;
return (NULL);
}
if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1 ||