From a7b82686a819cd0965636c6d068492f6bd20356c Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Tue, 3 May 2005 12:13:16 +0000 Subject: [PATCH] fix SIGSEGV when default style is used for "val" (ITS#3700) --- servers/slapd/aclparse.c | 93 +++++++++++++++++++++------------------- 1 file changed, 49 insertions(+), 44 deletions(-) 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.