From: Pierangelo Masarati Date: Tue, 4 Sep 2007 19:32:54 +0000 (+0000) Subject: parse unsigned as unsigned (ITS#5122) X-Git-Tag: OPENLDAP_REL_ENG_2_4_9~20^2~691 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=ed12ff8fd323544aef52fc8ab870dc15e180c9b4;p=openldap parse unsigned as unsigned (ITS#5122) --- diff --git a/servers/slapd/back-bdb/back-bdb.h b/servers/slapd/back-bdb/back-bdb.h index 51edd51c0b..369085005b 100644 --- a/servers/slapd/back-bdb/back-bdb.h +++ b/servers/slapd/back-bdb/back-bdb.h @@ -150,10 +150,10 @@ typedef struct bdb_cache { EntryInfo *c_lruhead; /* lru - add accessed entries here */ EntryInfo *c_lrutail; /* lru - rem lru entries from here */ EntryInfo c_dntree; - int c_maxsize; + unsigned c_maxsize; int c_cursize; - int c_minfree; - int c_eimax; + unsigned c_minfree; + unsigned c_eimax; int c_eiused; /* EntryInfo's in use */ int c_leaves; /* EntryInfo leaf nodes */ int c_purging; @@ -220,7 +220,7 @@ struct bdb_info { ID bi_lastid; ldap_pvt_thread_mutex_t bi_lastid_mutex; - int bi_idl_cache_max_size; + unsigned bi_idl_cache_max_size; int bi_idl_cache_size; Avlnode *bi_idl_tree; bdb_idl_cache_entry_t *bi_idl_lru_head; diff --git a/servers/slapd/back-bdb/config.c b/servers/slapd/back-bdb/config.c index b21087a223..3844629cb4 100644 --- a/servers/slapd/back-bdb/config.c +++ b/servers/slapd/back-bdb/config.c @@ -55,12 +55,12 @@ static ConfigTable bdbcfg[] = { "DESC 'Directory for database content' " "EQUALITY caseIgnoreMatch " "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL }, - { "cachefree", "size", 2, 2, 0, ARG_INT|ARG_OFFSET, + { "cachefree", "size", 2, 2, 0, ARG_UINT|ARG_OFFSET, (void *)offsetof(struct bdb_info, bi_cache.c_minfree), "( OLcfgDbAt:1.11 NAME 'olcDbCacheFree' " "DESC 'Number of extra entries to free when max is reached' " "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL }, - { "cachesize", "size", 2, 2, 0, ARG_INT|ARG_OFFSET, + { "cachesize", "size", 2, 2, 0, ARG_UINT|ARG_OFFSET, (void *)offsetof(struct bdb_info, bi_cache.c_maxsize), "( OLcfgDbAt:1.1 NAME 'olcDbCacheSize' " "DESC 'Entry cache size in entries' " @@ -86,13 +86,13 @@ static ConfigTable bdbcfg[] = { "( OLcfgDbAt:1.5 NAME 'olcDbDirtyRead' " "DESC 'Allow reads of uncommitted data' " "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL }, - { "dncachesize", "size", 2, 2, 0, ARG_INT|ARG_OFFSET, + { "dncachesize", "size", 2, 2, 0, ARG_UINT|ARG_OFFSET, (void *)offsetof(struct bdb_info, bi_cache.c_eimax), "( OLcfgDbAt:1.12 NAME 'olcDbDNcacheSize' " "DESC 'DN cache size' " "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL }, - { "idlcachesize", "size", 2, 2, 0, ARG_INT|ARG_OFFSET, - (void *)offsetof(struct bdb_info,bi_idl_cache_max_size), + { "idlcachesize", "size", 2, 2, 0, ARG_UINT|ARG_OFFSET, + (void *)offsetof(struct bdb_info, bi_idl_cache_max_size), "( OLcfgDbAt:1.6 NAME 'olcDbIDLcacheSize' " "DESC 'IDL cache size in IDLs' " "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL }, @@ -119,7 +119,7 @@ static ConfigTable bdbcfg[] = { bdb_cf_gen, "( OLcfgDbAt:1.9 NAME 'olcDbSearchStack' " "DESC 'Depth of search stack in IDLs' " "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL }, - { "shm_key", "key", 2, 2, 0, ARG_INT|ARG_OFFSET, + { "shm_key", "key", 2, 2, 0, ARG_LONG|ARG_OFFSET, (void *)offsetof(struct bdb_info, bi_shm_key), "( OLcfgDbAt:1.10 NAME 'olcDbShmKey' " "DESC 'Key for shared memory region' " diff --git a/servers/slapd/config.c b/servers/slapd/config.c index d6655a78a0..2bcc5e47f3 100644 --- a/servers/slapd/config.c +++ b/servers/slapd/config.c @@ -124,6 +124,7 @@ ConfigTable *config_find_keyword(ConfigTable *Conf, ConfigArgs *c) { int config_check_vals(ConfigTable *Conf, ConfigArgs *c, int check_only ) { int rc, arg_user, arg_type, arg_syn, iarg; + unsigned uiarg; long larg; ber_len_t barg; @@ -227,6 +228,16 @@ int config_check_vals(ConfigTable *Conf, ConfigArgs *c, int check_only ) { return(ARG_BAD_CONF); } break; + case ARG_UINT: + if ( lutil_atoux( &uiarg, c->argv[1], 0 ) != 0 ) { + snprintf( c->cr_msg, sizeof( c->cr_msg ), + "<%s> unable to parse \"%s\" as unsigned int", + c->argv[0], c->argv[1] ); + Debug(LDAP_DEBUG_CONFIG|LDAP_DEBUG_NONE, "%s: %s\n", + c->log, c->cr_msg, 0); + return(ARG_BAD_CONF); + } + break; case ARG_LONG: if ( lutil_atolx( &larg, c->argv[1], 0 ) != 0 ) { snprintf( c->cr_msg, sizeof( c->cr_msg ), @@ -283,6 +294,7 @@ int config_check_vals(ConfigTable *Conf, ConfigArgs *c, int check_only ) { switch(arg_type) { case ARG_ON_OFF: case ARG_INT: c->value_int = iarg; break; + case ARG_UINT: c->value_uint = uiarg; break; case ARG_LONG: c->value_long = larg; break; case ARG_BER_LEN_T: c->value_ber_t = barg; break; } @@ -333,6 +345,7 @@ int config_set_vals(ConfigTable *Conf, ConfigArgs *c) { switch(arg_type & ARGS_TYPES) { case ARG_ON_OFF: case ARG_INT: *(int*)ptr = c->value_int; break; + case ARG_UINT: *(unsigned*)ptr = c->value_uint; break; case ARG_LONG: *(long*)ptr = c->value_long; break; case ARG_BER_LEN_T: *(ber_len_t*)ptr = c->value_ber_t; break; case ARG_STRING: { @@ -419,6 +432,7 @@ config_get_vals(ConfigTable *cf, ConfigArgs *c) switch(cf->arg_type & ARGS_TYPES) { case ARG_ON_OFF: case ARG_INT: c->value_int = *(int *)ptr; break; + case ARG_UINT: c->value_uint = *(unsigned *)ptr; break; case ARG_LONG: c->value_long = *(long *)ptr; break; case ARG_BER_LEN_T: c->value_ber_t = *(ber_len_t *)ptr; break; case ARG_STRING: @@ -434,6 +448,7 @@ config_get_vals(ConfigTable *cf, ConfigArgs *c) bv.bv_val = c->log; switch(cf->arg_type & ARGS_TYPES) { case ARG_INT: bv.bv_len = snprintf(bv.bv_val, sizeof( c->log ), "%d", c->value_int); break; + case ARG_UINT: bv.bv_len = snprintf(bv.bv_val, sizeof( c->log ), "%u", c->value_uint); break; case ARG_LONG: bv.bv_len = snprintf(bv.bv_val, sizeof( c->log ), "%ld", c->value_long); break; case ARG_BER_LEN_T: bv.bv_len = snprintf(bv.bv_val, sizeof( c->log ), "%ld", c->value_ber_t); break; case ARG_ON_OFF: bv.bv_len = snprintf(bv.bv_val, sizeof( c->log ), "%s", diff --git a/servers/slapd/config.h b/servers/slapd/config.h index be5e2925a8..3664adcb82 100644 --- a/servers/slapd/config.h +++ b/servers/slapd/config.h @@ -55,6 +55,7 @@ typedef enum { #define ARG_STRING 0x00005000 #define ARG_BERVAL 0x00006000 #define ARG_DN 0x00007000 +#define ARG_UINT 0x00008000 #define ARGS_SYNTAX 0xffff0000 #define ARG_IGNORED 0x00080000 @@ -128,6 +129,7 @@ typedef struct config_args_s { /* parsed first val for simple cases */ union { int v_int; + unsigned v_uint; long v_long; ber_len_t v_ber_t; char *v_string; @@ -159,6 +161,7 @@ typedef struct config_args_s { #define CONFIG_ONLINE_ADD(ca) (!((ca)->lineno)) #define value_int values.v_int +#define value_uint values.v_uint #define value_long values.v_long #define value_ber_t values.v_ber_t #define value_string values.v_string