r7720: - simplify the asn1 decode of ldap_search() a lot, taking advantage of
authorAndrew Tridgell <tridge@samba.org>
Sat, 18 Jun 2005 10:38:06 +0000 (10:38 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:18:26 +0000 (13:18 -0500)
  the fact that the ldap data structures now use ldb_message_element.

- fixed null termination of elements in ildap

source/ldap_server/ldap_rootdse.c
source/libcli/ldap/ldap.c
source/libcli/ldap/ldap_msg.c
source/libcli/util/asn1.c

index 39e299ece153ef408aa1a316ba85454d2c148b79..d4e11e429a987f38cdd00d772597b62fdbaa2c00 100644 (file)
@@ -309,28 +309,16 @@ static NTSTATUS rootdse_Search(struct ldapsrv_partition *partition, struct ldaps
                        goto queue_reply;
                }
                ent->num_attributes = res[0]->num_elements;
-               ent->attributes = talloc_array(ent_r, struct ldb_message_element, ent->num_attributes);
-               NT_STATUS_HAVE_NO_MEMORY(ent->attributes);
+               ent->attributes = talloc_steal(ent_r, res[0]->elements);
+
                for (j=0; j < ent->num_attributes; j++) {
-                       ent->attributes[j].name = talloc_steal(ent->attributes, res[0]->elements[j].name);
-                       ent->attributes[j].num_values = 0;
-                       ent->attributes[j].values = NULL;
-                       ent->attributes[j].num_values = res[0]->elements[j].num_values;
                        if (ent->attributes[j].num_values == 1 &&
-                               strncmp(res[0]->elements[j].values[0].data, "_DYNAMIC_", 9) == 0) {
+                           ent->attributes[j].values[0].length >= 9 &&
+                           strncmp(ent->attributes[j].values[0].data, "_DYNAMIC_", 9) == 0) {
                                status = fill_dynamic_values(ent->attributes, &(ent->attributes[j]));
                                if (!NT_STATUS_IS_OK(status)) {
                                        return status;
                                }
-                       } else {
-                               ent->attributes[j].values = talloc_array(ent->attributes,
-                                                               DATA_BLOB, ent->attributes[j].num_values);
-                               NT_STATUS_HAVE_NO_MEMORY(ent->attributes[j].values);
-                               for (y=0; y < ent->attributes[j].num_values; y++) {
-                                       ent->attributes[j].values[y].length = res[0]->elements[j].values[y].length;
-                                       ent->attributes[j].values[y].data = talloc_steal(ent->attributes[j].values,
-                                                                               res[0]->elements[j].values[y].data);
-                               }
                        }
                }
 queue_reply:
index c642fc3e4b3de9eb5710950c50fbedec0ca80bf1..83858b176832c974adedbc2776651dc0549ba299 100644 (file)
@@ -98,6 +98,9 @@ static BOOL ldap_push_filter(struct asn1_data *data, struct ldb_parse_tree *tree
                asn1_pop_tag(data);
                break;
 
+       case LDB_OP_NOT:
+               #warning "OP_NOT missing"
+
        default:
                return False;
        }
@@ -605,7 +608,6 @@ static void ldap_decode_attrib(TALLOC_CTX *mem_ctx, struct asn1_data *data,
                DATA_BLOB blob;
                asn1_read_OctetString(data, &blob);
                add_value_to_attrib(mem_ctx, &blob, attrib);
-               data_blob_free(&blob);
        }
        asn1_end_tag(data);
        asn1_end_tag(data);
index 901c42a62a70817f514acb0c404902d1b1808e65..9b531f313802c3c64512b49839f11f3b69752774 100644 (file)
@@ -43,8 +43,9 @@ BOOL add_value_to_attrib(TALLOC_CTX *mem_ctx, struct ldb_val *value,
        if (attrib->values == NULL)
                return False;
 
-       attrib->values[attrib->num_values] =
-               data_blob_talloc(attrib->values, value->data, value->length);
+       attrib->values[attrib->num_values].data = talloc_steal(attrib->values, 
+                                                              value->data);
+       attrib->values[attrib->num_values].length = value->length;
        attrib->num_values += 1;
        return True;
 }
index 510ffa37cfceb7be2e7e9bd7d1918cc2dbcd035d..92f9a8c38969b2be07b3c038f478d4e62b19a299 100644 (file)
@@ -576,7 +576,6 @@ BOOL asn1_read_Integer(struct asn1_data *data, int *i)
        if (!asn1_start_tag(data, ASN1_INTEGER)) return False;
        if (!asn1_read_implicit_Integer(data, i)) return False;
        return asn1_end_tag(data);      
-       
 }
 
 /* read an interger */