From: Pierangelo Masarati Date: Tue, 3 May 2005 12:14:18 +0000 (+0000) Subject: fix SIGSEGV when default style is used for "val" (ITS#3700) X-Git-Tag: OPENLDAP_REL_ENG_2_2_27~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=93a3d8c714f948585a22531e903b6f00e4d50804;p=thirdparty%2Fopenldap.git fix SIGSEGV when default style is used for "val" (ITS#3700) --- diff --git a/CHANGES b/CHANGES index 7d36bad2b9..406bbbb602 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,7 @@ OpenLDAP 2.2 Change Log OpenLDAP 2.2.27 Engineering + Fixed ACL val default style parsing crasher (ITS#3700) OpenLDAP 2.2.26 Release Fixed back-bdb ldapadd ctxcsn crash (ITS#3685) diff --git a/servers/slapd/aclparse.c b/servers/slapd/aclparse.c index 0e1fa2f8b6..b12780afcb 100644 --- a/servers/slapd/aclparse.c +++ b/servers/slapd/aclparse.c @@ -281,49 +281,52 @@ 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; - - } else if ( a->acl_attrs[0].an_desc->ad_type->sat_syntax == slap_schema.si_syn_distinguishedName ) { - if ( !strcasecmp( style, "base" ) ) { + a->acl_attrval_style = ACL_STYLE_BASE; + if ( style ) { + 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 { + /* 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" ) ) { - a->acl_attrval_style = ACL_STYLE_SUBTREE; - } else if ( !strcasecmp( style, "children" ) ) { - a->acl_attrval_style = ACL_STYLE_CHILDREN; + + } else if ( a->acl_attrs[0].an_desc->ad_type->sat_syntax == slap_schema.si_syn_distinguishedName ) { + if ( !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.