]> git.sur5r.net Git - openldap/commitdiff
cleanup version parsing
authorPierangelo Masarati <ando@openldap.org>
Sat, 6 May 2006 10:42:29 +0000 (10:42 +0000)
committerPierangelo Masarati <ando@openldap.org>
Sat, 6 May 2006 10:42:29 +0000 (10:42 +0000)
servers/slapd/back-ldap/config.c
servers/slapd/back-meta/config.c

index ddf4e77ae086eb317106653bdf3c03f3b6f137a5..c0123fe8ebc20e915492f5a9b614d5c6b521ba42 100644 (file)
@@ -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 <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:
index 822a352a4ce2ee6d5b3ea686de9417e5a01b6eae..61434822cbfb93d33fd371e9bd742b69dc6d93f5 100644 (file)
@@ -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 <version>\"\n",
                                fname, lineno, argv[ 1 ] );