summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ldapd
diff options
context:
space:
mode:
authoryasuoka <yasuoka@openbsd.org>2019-03-31 03:36:18 +0000
committeryasuoka <yasuoka@openbsd.org>2019-03-31 03:36:18 +0000
commitef4f5895abd850e5705ba18ff094fe48eb3d06cd (patch)
treef62d986aaee36319a44d595489a7dad07f385254 /usr.sbin/ldapd
parentIf using retguard, we do not also need the stack protector. (diff)
downloadwireguard-openbsd-ef4f5895abd850e5705ba18ff094fe48eb3d06cd.tar.xz
wireguard-openbsd-ef4f5895abd850e5705ba18ff094fe48eb3d06cd.zip
Avoid calling dup2(oldd, newd) when oldd == newd. In that case the
descriptor keeps CLOEXEC flag then it will be closed unexpectedly by exec(). ok tedu florian
Diffstat (limited to 'usr.sbin/ldapd')
-rw-r--r--usr.sbin/ldapd/ldapd.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/usr.sbin/ldapd/ldapd.c b/usr.sbin/ldapd/ldapd.c
index 94df93ee4e6..797a36f89f3 100644
--- a/usr.sbin/ldapd/ldapd.c
+++ b/usr.sbin/ldapd/ldapd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldapd.c,v 1.24 2018/05/15 11:19:21 reyk Exp $ */
+/* $OpenBSD: ldapd.c,v 1.25 2019/03/31 03:36:18 yasuoka Exp $ */
/*
* Copyright (c) 2009, 2010 Martin Hedenfalk <martin@bzero.se>
@@ -429,7 +429,10 @@ start_child(enum ldapd_process p, char *argv0, int fd, int debug,
return (pid);
}
- if (dup2(fd, PROC_PARENT_SOCK_FILENO) == -1)
+ if (fd != PROC_PARENT_SOCK_FILENO) {
+ if (dup2(fd, PROC_PARENT_SOCK_FILENO) == -1)
+ fatal("cannot setup imsg fd");
+ } else if (fcntl(fd, F_SETFD, 0) == -1)
fatal("cannot setup imsg fd");
argv[argc++] = argv0;