From c905e31218aa7b801b3c055f842957d0b8dd7971 Mon Sep 17 00:00:00 2001
From: Quanah Gibson-Mount <quanah@openldap.org>
Date: Wed, 18 Nov 2009 18:04:30 +0000
Subject: [PATCH] ITS#6388

---
 CHANGES                    | 1 +
 doc/man/man3/ldap_result.3 | 6 +++++-
 libraries/libldap/result.c | 2 +-
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/CHANGES b/CHANGES
index 5e179135b9..4b3f57d966 100644
--- a/CHANGES
+++ b/CHANGES
@@ -7,6 +7,7 @@ OpenLDAP 2.4.20 Engineering
 	Fixed liblber to return failure on certain failures (ITS#6344)
 	Fixed libldap sasl buffer sizing (ITS#6327,ITS#6334)
 	Fixed libldap uninitialized return value (ITS#6355)
+	Fixed libldap unlimited timeout (ITS#6388)
 	Fixed liblutil constant (ITS#5909)
 	Added slapd handling of hex server IDs (ITS#6297)
 	Added slapd syncrepl contextCSN storing in subentry (ITS#6373)
diff --git a/doc/man/man3/ldap_result.3 b/doc/man/man3/ldap_result.3
index af572bb5fa..50e704fea5 100644
--- a/doc/man/man3/ldap_result.3
+++ b/doc/man/man3/ldap_result.3
@@ -48,7 +48,11 @@ is a NULL  pointer, the LDAP_OPT_TIMEOUT value set by
 is used. With the default setting,
 the  select  blocks  indefinitely.   To
 effect  a  poll,  the  timeout argument should be a non-NULL
-pointer, pointing to a zero-valued timeval structure.  See
+pointer, pointing to a zero-valued timeval structure.
+To obtain the behavior of the default setting, bypassing any value set by 
+.BR ldap_set_option (3),
+set to -1 the \fItv_sec\fP field of the \fItimeout\fP parameter.
+See
 .BR select (2)
 for further details.
 .LP
diff --git a/libraries/libldap/result.c b/libraries/libldap/result.c
index afdc236ea7..01f8d51cb1 100644
--- a/libraries/libldap/result.c
+++ b/libraries/libldap/result.c
@@ -276,7 +276,7 @@ wait4msg(
 	}
 #endif /* LDAP_DEBUG */
 
-	if ( timeout != NULL ) {
+	if ( timeout != NULL && timeout->tv_sec != -1 ) {
 		tv0 = *timeout;
 		tv = *timeout;
 		tvp = &tv;
-- 
GitLab