summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2005-06-01 18:56:00 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2005-06-01 18:56:00 +0000
commitb50b4bd1373e9c04c2d7b801ee3d7cd82c347e4a (patch)
treed1c495ba2a1d5f854e75f0e97e1b4718c92f5d79 /lib
parent000704c2c88eb754ffbdcaf56655f6904e58aeb4 (diff)
Save errno from clobbering by clsoedir() in the err case.
From Andrey Matveev; OK deraadt@
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/gen/getcwd.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/libc/gen/getcwd.c b/lib/libc/gen/getcwd.c
index a58988032be..5b9d5c6a609 100644
--- a/lib/libc/gen/getcwd.c
+++ b/lib/libc/gen/getcwd.c
@@ -28,7 +28,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: getcwd.c,v 1.12 2005/03/25 15:38:47 otto Exp $";
+static char rcsid[] = "$OpenBSD: getcwd.c,v 1.13 2005/06/01 18:55:59 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@@ -221,10 +221,15 @@ notfound:
errno = save_errno ? save_errno : ENOENT;
/* FALLTHROUGH */
err:
+ save_errno = errno;
+
if (ptsize)
free(pt);
free(up);
if (dir)
(void)closedir(dir);
+
+ errno = save_errno;
+
return (NULL);
}