diff options
author | 2017-12-07 05:06:08 +0000 | |
---|---|---|
committer | 2017-12-07 05:06:08 +0000 | |
commit | 84fa68aed71abd997e70e9a9caaad4c7bc52e67c (patch) | |
tree | e8207b124d5762926e3e9fbec9fadfe0ea532560 | |
parent | Let it compile again. (diff) | |
download | wireguard-openbsd-84fa68aed71abd997e70e9a9caaad4c7bc52e67c.tar.xz wireguard-openbsd-84fa68aed71abd997e70e9a9caaad4c7bc52e67c.zip |
Fix a potential fd leak in client_aldap_open().
okay jmatthew@
-rw-r--r-- | usr.sbin/ypldap/ldapclient.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/usr.sbin/ypldap/ldapclient.c b/usr.sbin/ypldap/ldapclient.c index 57bcb31e520..db4b0859e8b 100644 --- a/usr.sbin/ypldap/ldapclient.c +++ b/usr.sbin/ypldap/ldapclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldapclient.c,v 1.39 2017/05/30 09:33:31 jmatthew Exp $ */ +/* $OpenBSD: ldapclient.c,v 1.40 2017/12/07 05:06:08 zhuk Exp $ */ /* * Copyright (c) 2008 Alexander Schrijver <aschrijver@openbsd.org> @@ -66,7 +66,8 @@ struct aldap * client_aldap_open(struct ypldap_addr_list *addr) { int fd = -1; - struct ypldap_addr *p; + struct ypldap_addr *p; + struct aldap *al; TAILQ_FOREACH(p, addr, next) { char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV]; @@ -90,7 +91,10 @@ client_aldap_open(struct ypldap_addr_list *addr) if (fd == -1) return NULL; - return aldap_init(fd); + al = aldap_init(fd); + if (al == NULL) + close(fd); + return al; } int |