From: Kurt Zeilenga Date: Thu, 7 Jun 2001 22:47:02 +0000 (+0000) Subject: Check schema NAMEs X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~1342 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=67cf14466ee76083bb72919e5970700f9b639f51;p=openldap Check schema NAMEs --- diff --git a/servers/slapd/at.c b/servers/slapd/at.c index fd62fe0770..4859040aea 100644 --- a/servers/slapd/at.c +++ b/servers/slapd/at.c @@ -239,11 +239,19 @@ at_add( char *cname; if ( at->at_names && at->at_names[0] ) { + int i; + + for( i=0; at->at_names[i]; i++ ) { + if( !slap_valid_descr( at->at_names[i] ) ) { + return SLAP_SCHERR_BAD_DESCR; + } + } + cname = at->at_names[0]; + } else if ( at->at_oid ) { cname = at->at_oid; } else { - cname = ""; return SLAP_SCHERR_ATTR_INCOMPLETE; } diff --git a/servers/slapd/oc.c b/servers/slapd/oc.c index 5ecb0e73e5..d245e4a0d2 100644 --- a/servers/slapd/oc.c +++ b/servers/slapd/oc.c @@ -357,6 +357,16 @@ oc_add( ObjectClass *soc; int code; + if ( oc->oc_names != NULL ) { + int i; + + for( i=0; oc->oc_names[i]; i++ ) { + if( !slap_valid_descr( oc->oc_names[i] ) ) { + return SLAP_SCHERR_BAD_DESCR; + } + } + } + soc = (ObjectClass *) ch_calloc( 1, sizeof(ObjectClass) ); AC_MEMCPY( &soc->soc_oclass, oc, sizeof(LDAPObjectClass) ); diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 02b7de416c..df5afe25ca 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -13,6 +13,8 @@ LDAP_BEGIN_DECL LDAP_SLAPD_F( int ) schema_init_done; LDAP_SLAPD_F( struct slap_internal_schema ) slap_schema; +LDAP_SLAPD_F( int ) slap_valid_descr( const char * ); + LDAP_SLAPD_F (int) slap_str2ad LDAP_P(( const char *, AttributeDescription **ad, diff --git a/servers/slapd/schemaparse.c b/servers/slapd/schemaparse.c index 5370bf644b..cd73b41b0a 100644 --- a/servers/slapd/schemaparse.c +++ b/servers/slapd/schemaparse.c @@ -37,7 +37,8 @@ static char *const err2text[] = { "MatchingRule not found", "Syntax not found", "Syntax required", - "Qualifier not supported" + "Qualifier not supported", + "Invalid NAME" }; char * @@ -50,6 +51,24 @@ scherr2str(int code) } } +/* check schema descr validity */ +int slap_valid_descr( const char *descr ) +{ + int i=0; + + if( !DESC_LEADCHAR( descr[i] ) ) { + return 0; + } + + while( descr[++i] ) { + if( !DESC_CHAR( descr[i] ) ) { + return 0; + } + } + + return 1; +} + /* OID Macros */ diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index a012fb9cfb..cc1fd71257 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -216,6 +216,7 @@ typedef struct slap_ssf_set { #define SLAP_SCHERR_SYN_NOT_FOUND 13 #define SLAP_SCHERR_MR_INCOMPLETE 14 #define SLAP_SCHERR_NOT_SUPPORTED 15 +#define SLAP_SCHERR_BAD_DESCR 16 typedef struct slap_oid_macro { struct berval som_oid;