]> git.sur5r.net Git - openldap/commitdiff
Check for NULs in DNs.
authorKurt Zeilenga <kurt@openldap.org>
Wed, 13 Feb 2002 16:41:41 +0000 (16:41 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Wed, 13 Feb 2002 16:41:41 +0000 (16:41 +0000)
libraries/libldap/getdn.c
servers/slapd/dn.c

index af9d2154a62fd8f522981db77542d173a8f0cb85..3394ef0b539d5f75b76bd2f81fafbc86779cd47f 100644 (file)
@@ -648,8 +648,11 @@ ldap_bv2dn( struct berval *bv, LDAPDN **dn, unsigned flags )
                return LDAP_PARAM_ERROR;
        }
 
-       if ( str[ 0 ] == '\0' ) {
+       if ( bv->bv_len == 0 ) {
                return LDAP_SUCCESS;
+
+       } else if ( str[ 0 ] == '\0' ) {
+               return LDAP_DECODING_ERROR;
        }
 
        p = str;
@@ -873,8 +876,11 @@ ldap_bv2rdn( struct berval *bv, LDAPRDN **rdn,
                return LDAP_PARAM_ERROR;
        }
 
-       if ( str[ 0 ] == '\0' ) {
+       if ( bv->bv_len == 0 ) {
                return LDAP_SUCCESS;
+
+       } else if ( str[ 0 ] == '\0' ) {
+               return LDAP_DECODING_ERROR;
        }
 
        p = str;
index a3c1b7e3e76c45822021cc6b3c5d320c3824f790..47e012a0889b896649e74844a8f31f8118d8bba8 100644 (file)
@@ -117,20 +117,21 @@ dnValidate(
        }
 
        rc = ldap_bv2dn( in, &dn, LDAP_DN_FORMAT_LDAP );
+       if ( rc != LDAP_SUCCESS ) {
+               return LDAP_INVALID_SYNTAX;
+       }
+
+       assert( strlen( in->bv_val ) == in->bv_len );
 
        /*
         * Schema-aware validate
         */
+       rc = LDAPDN_validate( dn );
        if ( rc == LDAP_SUCCESS ) {
-               rc = LDAPDN_validate( dn );
                ldap_dnfree( dn );
        }
        
-       if ( rc != LDAP_SUCCESS ) {
-               return( LDAP_INVALID_SYNTAX );
-       }
-
-       return( LDAP_SUCCESS );
+       return LDAP_INVALID_SYNTAX;
 }
 
 /*
@@ -354,6 +355,8 @@ dnNormalize2(
                        return LDAP_INVALID_SYNTAX;
                }
 
+               assert( strlen( val->bv_val ) == val->bv_len );
+
                /*
                 * Schema-aware rewrite
                 */
@@ -425,6 +428,8 @@ dnPretty2(
                        return LDAP_INVALID_SYNTAX;
                }
 
+               assert( strlen( val->bv_val ) == val->bv_len );
+
                /*
                 * Schema-aware rewrite
                 */
@@ -485,6 +490,8 @@ dnPrettyNormal(
                        return LDAP_INVALID_SYNTAX;
                }
 
+               assert( strlen( val->bv_val ) == val->bv_len );
+
                /*
                 * Schema-aware rewrite
                 */