s4-ldb: ensure DNs pass validity tests in indexing
authorAndrew Tridgell <tridge@samba.org>
Sun, 25 Oct 2009 02:13:41 +0000 (13:13 +1100)
committerAndrew Tridgell <tridge@samba.org>
Sun, 25 Oct 2009 02:15:18 +0000 (13:15 +1100)
source4/lib/ldb/ldb_tdb/ldb_index.c

index 5002de527bf35ccc42e85cb0d1a64a7f57f7e0d5..252154ffd921041938393552e43facd5f99ad384 100644 (file)
@@ -401,6 +401,10 @@ static struct ldb_dn *ltdb_index_key(struct ldb_context *ldb,
        if (ldb_should_b64_encode(ldb, &v)) {
                char *vstr = ldb_base64_encode(ldb, (char *)v.data, v.length);
                if (!vstr) return NULL;
+               /* remove trailing '=' to make it a valid DN */
+               if (vstr[strlen(vstr)-1] == '=') {
+                       vstr[strlen(vstr)-1] = 0;
+               }
                ret = ldb_dn_new_fmt(ldb, ldb, "%s:%s::%s", LTDB_INDEX, attr_folded, vstr);
                talloc_free(vstr);
        } else {