From ee6d1a4d401b6e571b8e3d24df3766651ddab6f6 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Wed, 13 Feb 2002 16:41:41 +0000 Subject: [PATCH] Check for NULs in DNs. --- libraries/libldap/getdn.c | 10 ++++++++-- servers/slapd/dn.c | 19 +++++++++++++------ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/libraries/libldap/getdn.c b/libraries/libldap/getdn.c index af9d2154a6..3394ef0b53 100644 --- a/libraries/libldap/getdn.c +++ b/libraries/libldap/getdn.c @@ -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; diff --git a/servers/slapd/dn.c b/servers/slapd/dn.c index a3c1b7e3e7..47e012a088 100644 --- a/servers/slapd/dn.c +++ b/servers/slapd/dn.c @@ -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 */ -- 2.39.5