diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2005-03-01 13:51:48 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2005-03-01 13:51:48 +0000 |
commit | eb23a4e872f9a0d0ecc71f5b0d50babcfd73f29d (patch) | |
tree | 144a6eb0a3733344ccdd933b9697ef0439d71c77 /lib | |
parent | b889ed1331009b00b82c11cc7bc7276586bbd332 (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')
-rw-r--r-- | lib/libc/gen/opendir.c | 4 | ||||
-rw-r--r-- | lib/libc/gen/setmode.c | 6 |
2 files changed, 5 insertions, 5 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 || diff --git a/lib/libc/gen/setmode.c b/lib/libc/gen/setmode.c index 880fe192d2c..e530f09040d 100644 --- a/lib/libc/gen/setmode.c +++ b/lib/libc/gen/setmode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: setmode.c,v 1.15 2004/07/02 13:58:06 otto Exp $ */ +/* $OpenBSD: setmode.c,v 1.16 2005/03/01 13:51:47 miod Exp $ */ /* $NetBSD: setmode.c,v 1.15 1997/02/07 22:21:06 christos Exp $ */ /* @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)setmode.c 8.2 (Berkeley) 3/25/94"; #else -static char rcsid[] = "$OpenBSD: setmode.c,v 1.15 2004/07/02 13:58:06 otto Exp $"; +static char rcsid[] = "$OpenBSD: setmode.c,v 1.16 2005/03/01 13:51:47 miod Exp $"; #endif #endif /* LIBC_SCCS and not lint */ @@ -207,8 +207,8 @@ setmode(const char *p) perml = strtoul(p, &ep, 8); /* The test on perml will also catch overflow. */ if (*ep != '\0' || (perml & ~(STANDARD_BITS|S_ISTXT))) { - errno = ERANGE; free(saveset); + errno = ERANGE; return (NULL); } perm = (mode_t)perml; |