From: Kurt Zeilenga Date: Mon, 19 Apr 2004 20:45:26 +0000 (+0000) Subject: Additional invalid objectClass changes (ITS#3097) X-Git-Tag: OPENDLAP_REL_ENG_2_2_MP~474 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=69eeb79662d0670e4f56877aa49d0b8d1ddb22da;p=openldap Additional invalid objectClass changes (ITS#3097) catch error in validation/pretty functions --- diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 522fff8e72..b7c77caaff 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -1056,10 +1056,12 @@ LDAP_SLAPD_V( int ) schema_init_done; LDAP_SLAPD_F (int) slap_schema_init LDAP_P((void)); LDAP_SLAPD_F (void) schema_destroy LDAP_P(( void )); -LDAP_SLAPD_F( slap_mr_indexer_func ) octetStringIndexer; +LDAP_SLAPD_F( slap_syntax_validate_func ) numericoidValidate; +LDAP_SLAPD_F( slap_mr_indexer_func ) octetStringIndexer; LDAP_SLAPD_F( slap_mr_filter_func ) octetStringFilter; + /* * schema_prep.c */ diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index 499935beed..9465c17d67 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -1502,7 +1502,7 @@ telephoneNumberNormalize( return LDAP_SUCCESS; } -static int +int numericoidValidate( Syntax *syntax, struct berval *in ) diff --git a/servers/slapd/schema_prep.c b/servers/slapd/schema_prep.c index e0b082ad07..dffa3bf4fa 100644 --- a/servers/slapd/schema_prep.c +++ b/servers/slapd/schema_prep.c @@ -32,6 +32,20 @@ int schema_init_done = 0; struct slap_internal_schema slap_schema; +static int objectClassValidate( + Syntax *syntax, + struct berval *in ) +{ + ObjectClass *oc; + int rc = numericoidValidate( syntax, in ); + if ( rc ) return rc; + + oc = oc_bvfind( in ); + if( oc == NULL ) return LDAP_INVALID_SYNTAX; + + return LDAP_SUCCESS; +} + static int objectClassPretty( struct slap_syntax *syntax, struct berval * in, @@ -39,13 +53,9 @@ static int objectClassPretty( void *ctx ) { ObjectClass *oc = oc_bvfind( in ); + if( oc == NULL ) return LDAP_INVALID_SYNTAX; - if( oc != NULL ) { - ber_dupbv_x( out, &oc->soc_cname, ctx ); - } else { - ber_dupbv_x( out, in, ctx ); - } - + ber_dupbv_x( out, &oc->soc_cname, ctx ); return LDAP_SUCCESS; } @@ -283,7 +293,7 @@ static struct slap_schema_ad_map { "EQUALITY objectIdentifierMatch " "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )", NULL, SLAP_AT_FINAL, - NULL, objectClassPretty, + objectClassValidate, objectClassPretty, NULL, NULL, objectSubClassMatch, objectSubClassIndexer, objectSubClassFilter, offsetof(struct slap_internal_schema, si_ad_objectClass) }, @@ -295,7 +305,7 @@ static struct slap_schema_ad_map { "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 " "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )", NULL, 0, - NULL, objectClassPretty, + objectClassValidate, objectClassPretty, NULL, NULL, objectSubClassMatch, objectSubClassIndexer, objectSubClassFilter, offsetof(struct slap_internal_schema, si_ad_structuralObjectClass) },