]> git.sur5r.net Git - openldap/commitdiff
Check schema NAMEs
authorKurt Zeilenga <kurt@openldap.org>
Thu, 7 Jun 2001 22:47:02 +0000 (22:47 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Thu, 7 Jun 2001 22:47:02 +0000 (22:47 +0000)
servers/slapd/at.c
servers/slapd/oc.c
servers/slapd/proto-slap.h
servers/slapd/schemaparse.c
servers/slapd/slap.h

index fd62fe0770cb2aeb9c2608b259263302585519fd..4859040aea85865a111f6ba51b1d72a6e8eb0342 100644 (file)
@@ -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;
        }
 
index 5ecb0e73e534c1828a15553124ed93dc37b4e67a..d245e4a0d263bc0127c70b8871a4f50e3cef0bdc 100644 (file)
@@ -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) );
 
index 02b7de416cde067cfa5f3e7cd7ed7ca675366862..df5afe25ca6fd750fcb7c3e94a3b622aedd8aa84 100644 (file)
@@ -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,
index 5370bf644b1df094cc4f5c81946e10584d9f3629..cd73b41b0a69b70128263a1f11e88766249ae7a9 100644 (file)
@@ -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 */
 
index a012fb9cfb7693328fdb6780768fa506e405e936..cc1fd7125786f44fb999ff956bc732270e3f1c33 100644 (file)
@@ -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;