From: Pierangelo Masarati Date: Sat, 6 May 2006 10:42:29 +0000 (+0000) Subject: cleanup version parsing X-Git-Tag: OPENLDAP_REL_ENG_2_4_1ALPHA~2^2~77 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=470fda77449cad43bf6c70bf6ccba949f2e292ea;p=openldap cleanup version parsing --- diff --git a/servers/slapd/back-ldap/config.c b/servers/slapd/back-ldap/config.c index ddf4e77ae0..c0123fe8eb 100644 --- a/servers/slapd/back-ldap/config.c +++ b/servers/slapd/back-ldap/config.c @@ -1323,16 +1323,16 @@ done_url:; } break; case LDAP_BACK_CFG_VERSION: - switch ( c->value_int ) { - case 0: - case LDAP_VERSION2: - case LDAP_VERSION3: - li->li_version = c->value_int; - break; - - default: + if ( c->value_int != 0 && ( c->value_int < LDAP_VERSION_MIN || c->value_int > LDAP_VERSION_MAX ) ) { + snprintf( c->msg, sizeof( c->msg ), + "unsupported version \"%s\" " + "in \"protocol-version \"", + c->argv[ 1 ] ); + Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 ); return 1; } + + li->li_version = c->value_int; break; case LDAP_BACK_CFG_REWRITE: diff --git a/servers/slapd/back-meta/config.c b/servers/slapd/back-meta/config.c index 822a352a4c..61434822cb 100644 --- a/servers/slapd/back-meta/config.c +++ b/servers/slapd/back-meta/config.c @@ -1069,13 +1069,7 @@ meta_back_db_config( return 1; } - switch ( *version ) { - case 0: - case LDAP_VERSION2: - case LDAP_VERSION3: - break; - - default: + if ( *version != 0 && ( *version < LDAP_VERSION_MIN || *version > LDAP_VERSION_MAX ) ) { Debug( LDAP_DEBUG_ANY, "%s: line %d: unsupported version \"%s\" in \"protocol-version \"\n", fname, lineno, argv[ 1 ] );