static int oidValidate( Syntax *syntax, struct berval *in ) { struct berval val = *in; if( val.bv_len == 0 ) { /* disallow empty strings */ return LDAP_INVALID_SYNTAX; } if( DESC_LEADCHAR( val.bv_val[0] ) ) { val.bv_val++; val.bv_len--; if ( val.bv_len == 0 ) return LDAP_SUCCESS; while( DESC_CHAR( val.bv_val[0] ) ) { val.bv_val++; val.bv_len--; if ( val.bv_len == 0 ) return LDAP_SUCCESS; } } else { int sep = 0; while( OID_LEADCHAR( val.bv_val[0] ) ) { val.bv_val++; val.bv_len--; if ( val.bv_val[-1] != '0' ) { while ( OID_LEADCHAR( val.bv_val[0] )) { val.bv_val++; val.bv_len--; } } if( val.bv_len == 0 ) { if( sep == 0 ) break; return LDAP_SUCCESS; } if( !OID_SEPARATOR( val.bv_val[0] )) break; sep++; val.bv_val++; val.bv_len--; } } return LDAP_INVALID_SYNTAX; }
/* 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; }
/* Define an attribute option. */ int ad_define_option( const char *name, const char *fname, int lineno ) { int i; unsigned int optlen; if ( options == &lang_option ) { options = NULL; option_count = 0; } if ( name == NULL ) return 0; optlen = 0; do { if ( !DESC_CHAR( name[optlen] ) ) { /* allow trailing '=', same as '-' */ if ( name[optlen] == '=' && !name[optlen+1] ) { msad_range_hack = 1; continue; } Debug( LDAP_DEBUG_ANY, "%s: line %d: illegal option name \"%s\"\n", fname, lineno, name ); return 1; } } while ( name[++optlen] ); options = ch_realloc( options, (option_count+1) * sizeof(Attr_option) ); if ( strcasecmp( name, "binary" ) == 0 || ad_find_option_definition( name, optlen ) ) { Debug( LDAP_DEBUG_ANY, "%s: line %d: option \"%s\" is already defined\n", fname, lineno, name ); return 1; } for ( i = option_count; i; --i ) { if ( strcasecmp( name, options[i-1].name.bv_val ) >= 0 ) break; options[i] = options[i-1]; } options[i].name.bv_val = ch_strdup( name ); options[i].name.bv_len = optlen; options[i].prefix = (name[optlen-1] == '-') || (name[optlen-1] == '='); if ( i != option_count && options[i].prefix && optlen < options[i+1].name.bv_len && strncasecmp( name, options[i+1].name.bv_val, optlen ) == 0 ) { Debug( LDAP_DEBUG_ANY, "%s: line %d: option \"%s\" overrides previous option\n", fname, lineno, name ); return 1; } option_count++; return 0; }