s4/ldap: Fix nested searches SEGFAULT bug
authorKamen Mazdrashki <kamen.mazdrashki@postpath.com>
Mon, 25 Jan 2010 10:22:39 +0000 (12:22 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 29 Jan 2010 13:09:53 +0000 (14:09 +0100)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
source4/lib/ldb/ldb_ildap/ldb_ildap.c
source4/libcli/ldap/ldap_client.h

index 53257a1ab09dd8a5da2ab337e58fb4b8ece7f653..6eb2e1719c8b2b50abe52506037b9263e01c1e74 100644 (file)
@@ -278,6 +278,13 @@ static void ildb_callback(struct ldap_request *req)
                break;
 
        case LDAP_TAG_SearchRequest:
                break;
 
        case LDAP_TAG_SearchRequest:
+               /* check if we are already processing this request */
+               if (req->in_dispatch_replies) {
+                       return;
+               }
+
+               req->in_dispatch_replies = true;
+
                /* loop over all messages */
                for (i = 0; i < req->num_replies; i++) {
 
                /* loop over all messages */
                for (i = 0; i < req->num_replies; i++) {
 
@@ -327,6 +334,7 @@ static void ildb_callback(struct ldap_request *req)
                                if (ret != LDB_SUCCESS) {
                                        callback_failed = true;
                                }
                                if (ret != LDB_SUCCESS) {
                                        callback_failed = true;
                                }
+
                                break;
 
                        case LDAP_TAG_SearchResultReference:
                                break;
 
                        case LDAP_TAG_SearchResultReference:
@@ -337,6 +345,7 @@ static void ildb_callback(struct ldap_request *req)
                                if (ret != LDB_SUCCESS) {
                                        callback_failed = true;
                                }
                                if (ret != LDB_SUCCESS) {
                                        callback_failed = true;
                                }
+
                                break;
 
                        default:
                                break;
 
                        default:
@@ -350,6 +359,8 @@ static void ildb_callback(struct ldap_request *req)
                        }
                }
 
                        }
                }
 
+               req->in_dispatch_replies = false;
+
                talloc_free(req->replies);
                req->replies = NULL;
                req->num_replies = 0;
                talloc_free(req->replies);
                req->replies = NULL;
                req->num_replies = 0;
index 084de2e6dc3cac59d7b27321494957ff42aa464b..d6ca29f8a7dac13ef2ca5cd427fd3c5e6825b732 100644 (file)
@@ -37,6 +37,10 @@ struct ldap_request {
        int num_replies;
        struct ldap_message **replies;
 
        int num_replies;
        struct ldap_message **replies;
 
+       /* mark while we are processing replies
+        * in request of type LDAP_TAG_SearchRequest */
+       bool in_dispatch_replies;
+
        NTSTATUS status;
        DATA_BLOB data;
        struct {
        NTSTATUS status;
        DATA_BLOB data;
        struct {