From: Pierangelo Masarati Date: Tue, 3 May 2005 12:13:16 +0000 (+0000) Subject: fix SIGSEGV when default style is used for "val" (ITS#3700) X-Git-Tag: OPENLDAP_AC_BP~753 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=a7b82686a819cd0965636c6d068492f6bd20356c;p=openldap fix SIGSEGV when default style is used for "val" (ITS#3700) --- diff --git a/servers/slapd/aclparse.c b/servers/slapd/aclparse.c index b0bed6579c..7a099972a6 100644 --- a/servers/slapd/aclparse.c +++ b/servers/slapd/aclparse.c @@ -438,8 +438,9 @@ parse_acl( acl_usage(); } - } else if ( strcasecmp( left, "attr" ) == 0 - || strcasecmp( left, "attrs" ) == 0 ) { + } else if ( strcasecmp( left, "attr" ) == 0 /* TOLERATED */ + || strcasecmp( left, "attrs" ) == 0 ) /* DOCUMENTED */ + { a->acl_attrs = str2anlist( a->acl_attrs, right, "," ); if ( a->acl_attrs == NULL ) { @@ -464,58 +465,62 @@ parse_acl( acl_usage(); } ber_str2bv( right, 0, 1, &a->acl_attrval ); - if ( style && strcasecmp( style, "regex" ) == 0 ) { - int e = regcomp( &a->acl_attrval_re, a->acl_attrval.bv_val, - REG_EXTENDED | REG_ICASE | REG_NOSUB ); - if ( e ) { - char buf[512]; - regerror( e, &a->acl_attrval_re, buf, sizeof(buf) ); - fprintf( stderr, "%s: line %d: " - "regular expression \"%s\" bad because of %s\n", - fname, lineno, right, buf ); - acl_usage(); - } - a->acl_attrval_style = ACL_STYLE_REGEX; - } else { - /* FIXME: if the attribute has DN syntax, we might - * allow one, subtree and children styles as well */ - if ( !strcasecmp( style, "exact" ) ) { - a->acl_attrval_style = ACL_STYLE_BASE; + a->acl_attrval_style = ACL_STYLE_BASE; + if ( style != NULL ) { + if ( strcasecmp( style, "regex" ) == 0 ) { + int e = regcomp( &a->acl_attrval_re, a->acl_attrval.bv_val, + REG_EXTENDED | REG_ICASE | REG_NOSUB ); + if ( e ) { + char buf[512]; + regerror( e, &a->acl_attrval_re, buf, sizeof(buf) ); + fprintf( stderr, "%s: line %d: " + "regular expression \"%s\" bad because of %s\n", + fname, lineno, right, buf ); + acl_usage(); + } + a->acl_attrval_style = ACL_STYLE_REGEX; - } else if ( a->acl_attrs[0].an_desc->ad_type-> - sat_syntax == slap_schema.si_syn_distinguishedName ) - { - if ( !strcasecmp( style, "baseObject" ) || - !strcasecmp( style, "base" ) ) - { + } else { + /* FIXME: if the attribute has DN syntax, we might + * allow one, subtree and children styles as well */ + if ( !strcasecmp( style, "exact" ) ) { a->acl_attrval_style = ACL_STYLE_BASE; - } else if ( !strcasecmp( style, "onelevel" ) || - !strcasecmp( style, "one" ) ) - { - a->acl_attrval_style = ACL_STYLE_ONE; - } else if ( !strcasecmp( style, "subtree" ) || - !strcasecmp( style, "sub" ) ) + + } else if ( a->acl_attrs[0].an_desc->ad_type-> + sat_syntax == slap_schema.si_syn_distinguishedName ) { - a->acl_attrval_style = ACL_STYLE_SUBTREE; - } else if ( !strcasecmp( style, "children" ) ) { - a->acl_attrval_style = ACL_STYLE_CHILDREN; + if ( !strcasecmp( style, "baseObject" ) || + !strcasecmp( style, "base" ) ) + { + a->acl_attrval_style = ACL_STYLE_BASE; + } else if ( !strcasecmp( style, "onelevel" ) || + !strcasecmp( style, "one" ) ) + { + a->acl_attrval_style = ACL_STYLE_ONE; + } else if ( !strcasecmp( style, "subtree" ) || + !strcasecmp( style, "sub" ) ) + { + a->acl_attrval_style = ACL_STYLE_SUBTREE; + } else if ( !strcasecmp( style, "children" ) ) { + a->acl_attrval_style = ACL_STYLE_CHILDREN; + } else { + fprintf( stderr, + "%s: line %d: unknown val.