]> git.sur5r.net Git - openldap/commitdiff
fix SIGSEGV when default style is used for "val" (ITS#3700)
authorPierangelo Masarati <ando@openldap.org>
Tue, 3 May 2005 12:13:16 +0000 (12:13 +0000)
committerPierangelo Masarati <ando@openldap.org>
Tue, 3 May 2005 12:13:16 +0000 (12:13 +0000)
servers/slapd/aclparse.c

index b0bed6579c37a9b1d8ce67321f21bda835f5bf30..7a099972a6970291ed48eab50ce58a74f6ed957e 100644 (file)
@@ -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.<style> \"%s\" "
+                                                                               "for attributeType \"%s\" with DN syntax; "
+                                                                               "using \"base\"\n",
+                                                                               fname, lineno, style,
+                                                                               a->acl_attrs[0].an_desc->ad_cname.bv_val );
+                                                                       a->acl_attrval_style = ACL_STYLE_BASE;
+                                                               }
+
                                                        } else {
                                                                fprintf( stderr, 
                                                                        "%s: line %d: unknown val.<style> \"%s\" "
-                                                                       "for attributeType \"%s\" with DN syntax; "
-                                                                       "using \"base\"\n",
+                                                                       "for attributeType \"%s\"; using \"exact\"\n",
                                                                        fname, lineno, style,
                                                                        a->acl_attrs[0].an_desc->ad_cname.bv_val );
                                                                a->acl_attrval_style = ACL_STYLE_BASE;
                                                        }
-
-                                               } else {
-                                                       fprintf( stderr, 
-                                                               "%s: line %d: unknown val.<style> \"%s\" "
-                                                               "for attributeType \"%s\"; using \"exact\"\n",
-                                                               fname, lineno, style,
-                                                               a->acl_attrs[0].an_desc->ad_cname.bv_val );
-                                                       a->acl_attrval_style = ACL_STYLE_BASE;
                                                }
                                        }