mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-30 13:30:57 +08:00
dn_validate/dn_normalize has been rewritten by
David A. Cooper <david.cooper@nist.gov> (ITS#1232) according to draft-ietf-ldapbis-dn-05.txt A copyright statement follows: The functions normalize_unicode(), get_hexpair(), write_hex_pair(), get_next_byte(), get_next_char(), get_ber_length(), ber_parse_primitive_string(), ber_parse_string(), String_normalize(), DirectoryString_normalize(), PrintableString_normalize(), IA5String_normalize(), ber_parse_primitive_bitstring(), ber_parse_bitstring(), getNext8bits(), bitString_normalize(), match_oid(), match_key(), get_validated_av_in_dn(), get_validated_rdn_in_dn(), and get_validated_dn() in this file were developed at the National Institute of Standards and Technology by employees of the Federal Government in the course of their official duties. Pursuant to title 17 Section 105 of the United States Code the code in these functions is not subject to copyright protection and is in the public domain. The copyright for all other code in this file is as specified below.
This commit is contained in:
parent
93923d4345
commit
a453d7eacf
2599
servers/slapd/dn.c
2599
servers/slapd/dn.c
File diff suppressed because it is too large
Load Diff
@ -313,6 +313,7 @@ LDAP_SLAPD_F (void) connection_internal_close( Connection *conn );
|
||||
* dn.c
|
||||
*/
|
||||
|
||||
LDAP_SLAPD_F (char *) get_validated_dn LDAP_P(( char *dn, int make_uppercase, int normalize ));
|
||||
LDAP_SLAPD_F (char *) dn_validate LDAP_P(( char *dn ));
|
||||
LDAP_SLAPD_F (char *) dn_normalize LDAP_P(( char *dn ));
|
||||
LDAP_SLAPD_F (char *) dn_parent LDAP_P(( Backend *be, const char *dn ));
|
||||
|
@ -233,12 +233,13 @@ dnValidate(
|
||||
|
||||
if( in->bv_len == 0 ) return LDAP_SUCCESS;
|
||||
|
||||
dn = ch_strdup( in->bv_val );
|
||||
dn = get_validated_dn( in->bv_val, 0, 0 );
|
||||
|
||||
rc = dn_validate( dn ) == NULL
|
||||
? LDAP_INVALID_SYNTAX : LDAP_SUCCESS;
|
||||
rc = ( dn == NULL ) ? LDAP_INVALID_SYNTAX : LDAP_SUCCESS;
|
||||
|
||||
if ( dn != NULL )
|
||||
ch_free( dn );
|
||||
|
||||
ch_free( dn );
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -250,25 +251,22 @@ dnNormalize(
|
||||
{
|
||||
struct berval *out;
|
||||
|
||||
if ( val->bv_len != 0 ) {
|
||||
char *dn;
|
||||
#ifdef USE_DN_NORMALIZE
|
||||
out = ber_bvstr( UTF8normalize( val->bv_val, UTF8_CASEFOLD ) );
|
||||
#else
|
||||
if ( val->bv_len == 0 ) {
|
||||
out = ber_bvdup( val );
|
||||
ldap_pvt_str2upper( out->bv_val );
|
||||
#endif
|
||||
dn = dn_validate( out->bv_val );
|
||||
|
||||
if( dn == NULL ) {
|
||||
ber_bvfree( out );
|
||||
return LDAP_INVALID_SYNTAX;
|
||||
}
|
||||
|
||||
out->bv_val = dn;
|
||||
out->bv_len = strlen( dn );
|
||||
} else {
|
||||
out = ber_bvdup( val );
|
||||
char *dn;
|
||||
#ifdef USE_DN_NORMALIZE
|
||||
dn = get_validated_dn( val->bv_val, 1, 1 );
|
||||
#else
|
||||
dn = get_validated_dn( val->bv_val, 0, 0 );
|
||||
#endif
|
||||
if( dn == NULL ) {
|
||||
return LDAP_INVALID_SYNTAX;
|
||||
}
|
||||
|
||||
out = (struct berval *)ch_malloc(sizeof(struct berval));
|
||||
out->bv_val = dn;
|
||||
out->bv_len = strlen( dn );
|
||||
}
|
||||
|
||||
*normalized = out;
|
||||
|
@ -71,10 +71,12 @@ LDAP_BEGIN_DECL
|
||||
|
||||
/* We assume "C" locale, that is US-ASCII */
|
||||
#define ASCII_SPACE(c) ( (c) == ' ' )
|
||||
#define ASCII_WHITESPACE(c) ( (c) == ' ' || (c) == '\f' || (c) == '\n' || (c) == '\r' || (c) == '\t' || (c) == '\v' )
|
||||
#define ASCII_LOWER(c) ( (c) >= 'a' && (c) <= 'z' )
|
||||
#define ASCII_UPPER(c) ( (c) >= 'A' && (c) <= 'Z' )
|
||||
#define ASCII_ALPHA(c) ( ASCII_LOWER(c) || ASCII_UPPER(c) )
|
||||
#define ASCII_DIGIT(c) ( (c) >= '0' && (c) <= '9' )
|
||||
#define ASCII_XDIGIT(c) ( ASCII_DIGIT(c) || ( (c) >= 'A' && (c) <= 'F') || ( (c) >= 'a' && (c) <= 'f' ) )
|
||||
#define ASCII_ALNUM(c) ( ASCII_ALPHA(c) || ASCII_DIGIT(c) )
|
||||
#define ASCII_PRINTABLE(c) ( (c) >= ' ' && (c) <= '~' )
|
||||
|
||||
@ -90,6 +92,7 @@ LDAP_BEGIN_DECL
|
||||
#define RDN_ATTRTYPEANDVALUE_SEPARATOR(c) ((c) == '+') /* RFC 2253 */
|
||||
#define RDN_SEPARATOR(c) (DN_SEPARATOR(c) || RDN_ATTRTYPEANDVALUE_SEPARATOR(c))
|
||||
#define RDN_NEEDSESCAPE(c) ((c) == '\\' || (c) == '"')
|
||||
#define RDN_SPECIAL(c) ( (c) == ',' || (c) == '+' || (c) == '<' || (c) == '>' || (c) == ';' )
|
||||
|
||||
#define DESC_LEADCHAR(c) ( ASCII_ALPHA(c) )
|
||||
#define DESC_CHAR(c) ( ASCII_ALNUM(c) || (c) == '-' )
|
||||
@ -110,6 +113,7 @@ LDAP_BEGIN_DECL
|
||||
(c) == '-' || (c) == '.' || (c) == '/' || (c) == ':' || \
|
||||
(c) == '?' || (c) == ' ' || (c) == '=' )
|
||||
#define SLAP_PRINTABLES(c) ( SLAP_PRINTABLE(c) || (c) == '$' )
|
||||
#define SLAP_IA5(c) ( (c) <= 127 )
|
||||
|
||||
/* must match in schema_init.c */
|
||||
#define SLAPD_DN_SYNTAX "1.3.6.1.4.1.1466.115.121.1.12"
|
||||
|
Loading…
Reference in New Issue
Block a user