]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/mr.c
fix NOOP return code (ITS#4563; I'll check and confirm it later; NOOP support might...
[openldap] / servers / slapd / mr.c
index 77e070b5952034fca924e4a34181d82b71681b96..4ca235e7e518df32e7d2c04bd84f01f37eba7c2f 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2006 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -23,7 +23,6 @@
 #include <ac/socket.h>
 
 #include "slap.h"
-#include "ldap_pvt.h"
 
 struct mindexrec {
        struct berval   mir_name;
@@ -46,7 +45,7 @@ mr_index_cmp(
        const struct mindexrec  *mir2 = v_mir2;
        int i = mir1->mir_name.bv_len - mir2->mir_name.bv_len;
        if (i) return i;
-       return (strcmp( mir1->mir_name.bv_val, mir2->mir_name.bv_val ));
+       return (strcasecmp( mir1->mir_name.bv_val, mir2->mir_name.bv_val ));
 }
 
 static int
@@ -59,7 +58,7 @@ mr_index_name_cmp(
        const struct mindexrec *mir  = v_mir;
        int i = name->bv_len - mir->mir_name.bv_len;
        if (i) return i;
-       return (strncmp( name->bv_val, mir->mir_name.bv_val, name->bv_len ));
+       return (strncasecmp( name->bv_val, mir->mir_name.bv_val, name->bv_len ));
 }
 
 MatchingRule *
@@ -170,6 +169,7 @@ mr_add(
                for( i=0; def->mrd_compat_syntaxes[i]; i++ ) {
                        compat_syn[i] = syn_find( def->mrd_compat_syntaxes[i] );
                        if( compat_syn[i] == NULL ) {
+                               ch_free( compat_syn );
                                return SLAP_SCHERR_SYN_NOT_FOUND;
                        }
                }
@@ -199,10 +199,12 @@ mr_add(
                        smr->smr_syntax = syn;
                } else {
                        *err = smr->smr_syntax_oid;
+                       ch_free( smr );
                        return SLAP_SCHERR_SYN_NOT_FOUND;
                }
        } else {
                *err = "";
+               ch_free( smr );
                return SLAP_SCHERR_MR_INCOMPLETE;
        }
        code = mr_insert(smr,err);
@@ -218,9 +220,7 @@ register_matching_rule(
        int             code;
        const char      *err;
 
-       if( def->mrd_usage == SLAP_MR_NONE &&
-               def->mrd_compat_syntaxes == NULL )
-       {
+       if( def->mrd_usage == SLAP_MR_NONE && def->mrd_compat_syntaxes == NULL ) {
                Debug( LDAP_DEBUG_ANY, "register_matching_rule: not usable %s\n",
                    def->mrd_desc, 0, 0 );
 
@@ -229,10 +229,9 @@ register_matching_rule(
 
        if( def->mrd_associated != NULL ) {
                amr = mr_find( def->mrd_associated );
-
                if( amr == NULL ) {
-                       Debug( LDAP_DEBUG_ANY, "register_matching_rule: could not locate "
-                               "associated matching rule %s for %s\n",
+                       Debug( LDAP_DEBUG_ANY, "register_matching_rule: "
+                               "could not locate associated matching rule %s for %s\n",
                                def->mrd_associated, def->mrd_desc, 0 );
 
                        return -1;
@@ -244,17 +243,15 @@ register_matching_rule(
                        if (( def->mrd_usage & SLAP_MR_EQUALITY ) &&
                                (( def->mrd_usage & SLAP_MR_SUBTYPE_MASK ) != SLAP_MR_NONE ))
                        {
-                               Debug( LDAP_DEBUG_ANY,
-                                  "register_matching_rule: inappropriate (approx) association "
-                                               "%s for %s\n",
+                               Debug( LDAP_DEBUG_ANY, "register_matching_rule: "
+                                               "inappropriate (approx) association %s for %s\n",
                                        def->mrd_associated, def->mrd_desc, 0 );
                                return -1;
                        }
 
                } else if (!( amr->smr_usage & SLAP_MR_EQUALITY )) {
-                               Debug( LDAP_DEBUG_ANY,
-                                  "register_matching_rule: inappropriate (equalilty) association "
-                                               "%s for %s\n",
+                               Debug( LDAP_DEBUG_ANY, "register_matching_rule: "
+                                       "inappropriate (equalilty) association %s for %s\n",
                                        def->mrd_associated, def->mrd_desc, 0 );
                                return -1;
                }