]> git.sur5r.net Git - openldap/commitdiff
check we don't exceed userland with config param bits
authorPierangelo Masarati <ando@openldap.org>
Sat, 19 Nov 2005 18:01:28 +0000 (18:01 +0000)
committerPierangelo Masarati <ando@openldap.org>
Sat, 19 Nov 2005 18:01:28 +0000 (18:01 +0000)
servers/slapd/back-ldap/chain.c
servers/slapd/back-ldap/config.c
servers/slapd/config.h

index 8207eca7172aea4fc009e6f7b8a55a8b104a5565..d06fe256658ec7db474b8b69a83556bd04c21599 100644 (file)
@@ -858,10 +858,10 @@ str2chain( const char *s )
  */
 
 enum {
-       PC_CHAINING = 1,
-       PC_CACHE_URI = 2,
+       CH_CHAINING = 1,
+       CH_CACHE_URI = 2,
 
-       PC_LAST
+       CH_LAST
 };
 
 #ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
@@ -873,13 +873,13 @@ static ConfigLDAPadd chain_ldadd;
 static ConfigTable chaincfg[] = {
 #ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
        { "chain-chaining", "args",
-               2, 4, 0, ARG_MAGIC|ARG_BERVAL|PC_CHAINING, chain_cf_gen,
+               2, 4, 0, ARG_MAGIC|ARG_BERVAL|CH_CHAINING, chain_cf_gen,
                "( OLcfgOvAt:3.1 NAME 'olcChainingBehavior' "
                        "DESC 'Chaining behavior control parameters (draft-sermersheim-ldap-chaining)' "
                        "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
 #endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */
        { "chain-cache-uris", "TRUE/FALSE",
-               2, 2, 0, ARG_MAGIC|ARG_ON_OFF|PC_CACHE_URI, chain_cf_gen,
+               2, 2, 0, ARG_MAGIC|ARG_ON_OFF|CH_CACHE_URI, chain_cf_gen,
                "( OLcfgOvAt:3.2 NAME 'olcCacheURIs' "
                        "DESC 'Enables caching of URIs not present in configuration' "
                        "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
@@ -999,7 +999,7 @@ chain_cf_gen( ConfigArgs *c )
        if ( c->op == SLAP_CONFIG_EMIT ) {
                switch( c->type ) {
 #ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
-               case PC_CHAINING: {
+               case CH_CHAINING: {
                        struct berval   resolve = BER_BVNULL,
                                        continuation = BER_BVNULL;
 
@@ -1030,7 +1030,7 @@ chain_cf_gen( ConfigArgs *c )
                }
 #endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */
 
-               case PC_CACHE_URI:
+               case CH_CACHE_URI:
                        c->value_int = LDAP_CHAIN_CACHE_URI( lc );
                        break;
 
@@ -1042,10 +1042,10 @@ chain_cf_gen( ConfigArgs *c )
 
        } else if ( c->op == LDAP_MOD_DELETE ) {
                switch( c->type ) {
-               case PC_CHAINING:
+               case CH_CHAINING:
                        return 1;
 
-               case PC_CACHE_URI:
+               case CH_CACHE_URI:
                        lc->lc_flags &= ~LDAP_CHAIN_F_CACHE_URI;
                        break;
 
@@ -1057,7 +1057,7 @@ chain_cf_gen( ConfigArgs *c )
 
        switch( c->type ) {
 #ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
-       case PC_CHAINING: {
+       case CH_CHAINING: {
                char                    **argv = c->argv;
                int                     argc = c->argc;
                BerElementBuffer        berbuf;
@@ -1172,7 +1172,7 @@ chain_cf_gen( ConfigArgs *c )
        }
 #endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */
 
-       case PC_CACHE_URI:
+       case CH_CACHE_URI:
                if ( c->value_int ) {
                        lc->lc_flags |= LDAP_CHAIN_F_CACHE_URI;
                } else {
@@ -1621,7 +1621,8 @@ chain_init( void )
 {
        int     rc;
 
-       assert( PC_LAST <= ARGS_USERLAND );
+       /* Make sure we don't exceed the bits reserved for userland */
+       config_check_userland( CH_LAST );
 
 #ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
        rc = register_supported_control( LDAP_CONTROL_X_CHAINING_BEHAVIOR,
index eb1c157851f39c4807511544ae334a132721acc0..b7e3ecedf83e7174b7f717fa71d945d5ca5156aa 100644 (file)
@@ -60,7 +60,9 @@ enum {
        LDAP_BACK_CFG_T_F,
        LDAP_BACK_CFG_WHOAMI,
        LDAP_BACK_CFG_TIMEOUT,
-       LDAP_BACK_CFG_REWRITE
+       LDAP_BACK_CFG_REWRITE,
+
+       LDAP_BACK_CFG_LAST
 };
 
 static ConfigTable ldapcfg[] = {
@@ -1132,6 +1134,9 @@ ldap_back_init_cf( BackendInfo *bi )
        AttributeDescription    *ad = NULL;
        const char              *text;
 
+       /* Make sure we don't exceed the bits reserved for userland */
+       config_check_userland( LDAP_BACK_CFG_LAST );
+
        bi->bi_cf_ocs = ldapocs;
 
        rc = config_register_schema( ldapcfg, ldapocs );
index 3dc25928031df9e67f4e24142fecf50b8fcee7fb..a1ca2208ece40a353caa8f07b6963b868899e018 100644 (file)
@@ -14,6 +14,9 @@
  * <http://www.OpenLDAP.org/license.html>.
  */
 
+#ifndef CONFIG_H
+#define CONFIG_H
+
 typedef struct ConfigTable {
        char *name;
        char *what;
@@ -169,3 +172,9 @@ int read_config_file(const char *fname, int depth, ConfigArgs *cf,
 ConfigTable * config_find_keyword(ConfigTable *ct, ConfigArgs *c);
 Entry * config_build_entry( Operation *op, SlapReply *rs, CfEntryInfo *parent,
        ConfigArgs *c, struct berval *rdn, ConfigOCs *main, ConfigOCs *extra );
+
+       /* Make sure we don't exceed the bits reserved for userland */
+#define        config_check_userland(last) \
+       assert( ( ( (last) - 1 ) & ARGS_USERLAND ) == ( (last) - 1 ) );
+
+#endif /* CONFIG_H */