s4:dsdb Ensure we allow 'odd' lengths for DN+String
authorAndrew Bartlett <abartlet@samba.org>
Sat, 7 Nov 2009 01:06:11 +0000 (12:06 +1100)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 11 Nov 2009 21:11:18 +0000 (08:11 +1100)
(Found in a code review by metze)

Andrew Bartlett

source4/dsdb/common/dsdb_dn.c

index 3605a6a0562311e9ee7419129a607ce81b5e8d3b..6c20d099100d20ca723388ff151ac86dce1f973a 100644 (file)
@@ -149,11 +149,6 @@ struct dsdb_dn *dsdb_dn_parse(TALLOC_CTX *mem_ctx, struct ldb_context *ldb,
        p1 = p2+1;
        len--;
                
-       if ((blen % 2 != 0)) {
-               DEBUG(10, (__location__ ": blen=%u - not an even number\n", (unsigned)blen));
-               goto failed;
-       }
-               
        if (blen >= len) {
                DEBUG(10, (__location__ ": blen=%u len=%u\n", (unsigned)blen, (unsigned)len));
                goto failed;
@@ -169,6 +164,11 @@ struct dsdb_dn *dsdb_dn_parse(TALLOC_CTX *mem_ctx, struct ldb_context *ldb,
                
        switch (dn_format) {
        case DSDB_BINARY_DN:
+               if ((blen % 2 != 0)) {
+                       DEBUG(10, (__location__ ": blen=%u - not an even number\n", (unsigned)blen));
+                       goto failed;
+               }
+               
                if (blen >= 2) {
                        bval.length = (blen/2)+1;
                        bval.data = talloc_size(tmp_ctx, bval.length);