]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/result.c
ITS#6689
[openldap] / libraries / libldap / result.c
index afdc236ea7eb2d20e624f4bacddb86696e01c960..05580b793cfa8215566cb412215f35021927bf8b 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2009 The OpenLDAP Foundation.
+ * Copyright 1998-2010 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -276,7 +276,7 @@ wait4msg(
        }
 #endif /* LDAP_DEBUG */
 
-       if ( timeout != NULL ) {
+       if ( timeout != NULL && timeout->tv_sec != -1 ) {
                tv0 = *timeout;
                tv = *timeout;
                tvp = &tv;
@@ -747,8 +747,9 @@ nextresp2:
                        }
 
                        /* Do we need to check for referrals? */
-                       if ( LDAP_BOOL_GET(&ld->ld_options, LDAP_BOOL_REFERRALS) ||
-                                       lr->lr_parent != NULL )
+                       if ( tag != LDAP_RES_BIND &&
+                               ( LDAP_BOOL_GET(&ld->ld_options, LDAP_BOOL_REFERRALS) ||
+                                       lr->lr_parent != NULL ))
                        {
                                char            **refs = NULL;
                                ber_len_t       len;
@@ -993,6 +994,7 @@ nextresp2:
 
                        /* need to return -1, because otherwise
                         * a valid result is expected */
+                       ld->ld_errno = lderr;
                        return -1;
                }
        }