]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/search.c
ITS#5300
[openldap] / libraries / libldap / search.c
index 762bfd2fe7abd4999fd9365d75f72dcea8d9c7a2..7c6f62b977d180d40824f2c2cedb9a0578087c6c 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2006 The OpenLDAP Foundation.
+ * Copyright 1998-2007 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -259,8 +259,9 @@ ldap_build_search_req(
        LDAP_NEXT_MSGID( ld, *idp );
 #ifdef LDAP_CONNECTIONLESS
        if ( LDAP_IS_UDP(ld) ) {
-           err = ber_write( ber, ld->ld_options.ldo_peer,
-                   sizeof(struct sockaddr), 0);
+               struct sockaddr sa = {0};
+               /* dummy, filled with ldo_peer in request.c */
+           err = ber_write( ber, &sa, sizeof( sa ), 0 );
        }
        if ( LDAP_IS_UDP(ld) && ld->ld_options.ldo_version == LDAP_VERSION2) {
            char *dn = ld->ld_options.ldo_cldapdn;
@@ -357,7 +358,7 @@ ldap_search_st(
            == -1 )
                return( ld->ld_errno );
 
-       if ( ldap_result( ld, msgid, LDAP_MSG_ALL, timeout, res ) == -1 )
+       if ( ldap_result( ld, msgid, LDAP_MSG_ALL, timeout, res ) == -1 || !*res )
                return( ld->ld_errno );
 
        if ( ld->ld_errno == LDAP_TIMEOUT ) {
@@ -385,7 +386,7 @@ ldap_search_s(
            == -1 )
                return( ld->ld_errno );
 
-       if ( ldap_result( ld, msgid, LDAP_MSG_ALL, (struct timeval *) NULL, res ) == -1 )
+       if ( ldap_result( ld, msgid, LDAP_MSG_ALL, (struct timeval *) NULL, res ) == -1 || !*res )
                return( ld->ld_errno );
 
        return( ldap_result2error( ld, *res, 0 ) );