#define TMP_AVA_SLOTS 8
#define TMP_RDN_SLOTS 32
+int
+ldap_bv2dn( struct berval *bv, LDAPDN **dn, unsigned flags )
+{
+ assert( bv );
+ assert( dn );
+
+ /*
+ * FIXME: ldap_bv2dn() and ldap_str2dn() will be swapped,
+ * i.e. ldap_str2dn() will become a wrapper for ldap_bv2dn()
+ */
+ if ( bv->bv_len != strlen( bv->bv_val ) ) {
+ return LDAP_INVALID_DN_SYNTAX;
+ }
+
+ return ldap_str2dn( bv->bv_val, dn, flags );
+}
+
int
ldap_str2dn( LDAP_CONST char *str, LDAPDN **dn, unsigned flags )
{
goto parsing_error;
}
p++;
-
+
+ /*
+ * actually we do not want to accept by default the DCE form,
+ * we do not want to auto-detect it
+ */
+#if 0
} else if ( LDAP_DN_LDAP( flags ) ) {
/*
* if dn starts with '/' let's make it a DCE dn
flags |= LDAP_DN_FORMAT_DCE;
p++;
}
+#endif
}
for ( ; p[ 0 ]; p++ ) {
assert( rdn || flags & LDAP_DN_SKIP );
assert( n );
+#if 0
Debug( LDAP_DEBUG_TRACE, "=> ldap_str2rdn(%s,%u)\n%s", str, flags, "" );
+#endif
if ( rdn ) {
*rdn = NULL;
LDAP_FREE( tmpRDN );
}
+#if 0
Debug( LDAP_DEBUG_TRACE, "<= ldap_str2rdn(%*s)=%d\n",
p - str, str, rc );
+#endif
if ( rdn ) {
*rdn = newRDN;
continue;
}
- cl = LDAP_UTF8_CHARLEN( &val->bv_val[ s ] );
+ /*
+ * The length was checked in strval2strlen();
+ * LDAP_UTF8_CHARLEN() should suffice
+ */
+ cl = LDAP_UTF8_CHARLEN2( &val->bv_val[ s ], cl );
+ assert( cl > 0 );
/*
* there might be some chars we want to escape in form
int ( *sv2s ) ( struct berval *v, char *s, unsigned f, ber_len_t *l );
assert( bv );
-
bv->bv_len = 0;
bv->bv_val = NULL;
case LDAP_DN_FORMAT_LDAPV3:
sv2l = strval2strlen;
sv2s = strval2str;
- goto got_funcs;
+ if( 0 ) {
case LDAP_DN_FORMAT_LDAPV2:
- sv2l = strval2IA5strlen;
- sv2s = strval2IA5str;
-got_funcs:
-
+ sv2l = strval2IA5strlen;
+ sv2s = strval2IA5str;
+ }
+
for ( iRDN = 0, len = 0; dn[ 0 ][ iRDN ]; iRDN++ ) {
ber_len_t rdnl;
LDAPRDN *rdn = dn[ 0 ][ iRDN ];
break;
case LDAP_DN_FORMAT_UFN: {
-
/*
* FIXME: quoting from RFC 1781:
*
#endif /* DC_IN_UFN */
rc = LDAP_SUCCESS;
- break;
- }
- case LDAP_DN_FORMAT_DCE:
+ } break;
+ case LDAP_DN_FORMAT_DCE:
for ( iRDN = 0, len = 0; dn[ 0 ][ iRDN ]; iRDN++ ) {
ber_len_t rdnl;
LDAPRDN *rdn = dn[ 0 ][ iRDN ];
break;
case LDAP_DN_FORMAT_AD_CANONICAL: {
-
/*
* Sort of UFN for DCE DNs: a slash ('/') separated
* global->local DN with no types; strictly speaking,
bv->bv_val[ bv->bv_len ] = '\0';
rc = LDAP_SUCCESS;
- break;
- }
+ } break;
default:
return LDAP_PARAM_ERROR;
Debug( LDAP_DEBUG_TRACE, "<= ldap_dn2bv(%s,%u)=%d\n",
bv->bv_val, flags, rc );
+
return_results:;
return( rc );
}