r9771: - Prevent ldb crash when a invalid DN is added
authorJelmer Vernooij <jelmer@samba.org>
Tue, 30 Aug 2005 00:43:26 +0000 (00:43 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:34:59 +0000 (13:34 -0500)
- Don't silently drop records with empty attributes

tridge/simo: Could you please verify this patch is correct?
(This used to be commit 505c9b1d3d39475da141d3b3c156a7e5ba06790c)

source4/lib/ldb/common/ldb_attributes.c
source4/lib/ldb/common/ldb_ldif.c
source4/lib/ldb/common/ldb_msg.c

index a915666d78179623f0bc1e4eb05317c55a6e8178..3973fc515c525fbce40187587d6092d1b44cb9e6 100644 (file)
@@ -66,7 +66,7 @@ static int ldb_default_copy(struct ldb_context *ldb,
 {
        *out = ldb_val_dup(mem_ctx, in);
 
-       if (out->length == 0) {
+       if (out->data == NULL && in->data != NULL) {
                return -1;
        }
 
index 38866d703132af4b404dc53694650fcf56926048..a5768b979655ff39373c4494c95a71a59e8b49f1 100644 (file)
@@ -590,6 +590,12 @@ struct ldb_ldif *ldb_ldif_read(struct ldb_context *ldb,
 
        msg->dn = ldb_dn_explode(msg, value.data);
 
+       if (msg->dn == NULL) {
+               ldb_debug(ldb, LDB_DEBUG_ERROR, "Error: Unable to parse dn '%s'\n", 
+                                 value.data);
+               goto failed;
+       }
+
        while (next_attr(ldif, &s, &attr, &value) == 0) {
                const struct ldb_attrib_handler *h;             
                struct ldb_message_element *el;
index 197c42ddb5b51748765f60f4ed870896305b6aa6..f65c944eab9168b377f292037fef6886b8fbade1 100644 (file)
@@ -99,7 +99,7 @@ struct ldb_val ldb_val_dup(void *mem_ctx, const struct ldb_val *v)
 {
        struct ldb_val v2;
        v2.length = v->length;
-       if (v->length == 0) {
+       if (v->data == NULL) {
                v2.data = NULL;
                return v2;
        }