ldb:ldb_dn.c - don't support "ldb_dn_add_child" on a "" parent DN
authorMatthias Dieter Wallnöfer <mdw@samba.org>
Sat, 19 Jun 2010 12:49:23 +0000 (14:49 +0200)
committerMatthias Dieter Wallnöfer <mdw@samba.org>
Sat, 19 Jun 2010 15:53:23 +0000 (17:53 +0200)
It's meaningless and could end in DNs as "cn=child,".

source4/lib/ldb/common/ldb_dn.c

index 00646f6ba54418dcac2d57bee3e671a9980eaa5f..5ce735f145452f795b7e2a3efce7d6e151922f9d 100644 (file)
@@ -1488,6 +1488,10 @@ bool ldb_dn_add_child(struct ldb_dn *dn, struct ldb_dn *child)
                unsigned int n;
                long long int i, j;
 
+               if (dn->comp_num == 0) {
+                       return false;
+               }
+
                if ( ! ldb_dn_validate(child)) {
                        return false;
                }
@@ -1534,6 +1538,9 @@ bool ldb_dn_add_child(struct ldb_dn *dn, struct ldb_dn *child)
        }
 
        if (dn->linearized) {
+               if (dn->linearized[0] == '\0') {
+                       return false;
+               }
 
                s = ldb_dn_get_linearized(child);
                if ( ! s) {