]> git.sur5r.net Git - openldap/blobdiff - libraries/liblutil/passwd.c
fix test when slapo-memberof(5) built as module (ITS#5132)
[openldap] / libraries / liblutil / passwd.c
index 8f6fda6129ccbed43d772e5d594980255de2cfa3..2ccad563b2047984233644c87cd6821118eb1b29 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2005 The OpenLDAP Foundation.
+ * Copyright 1998-2007 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -73,6 +73,10 @@ static lutil_cryptfunc lutil_crypt;
 lutil_cryptfunc *lutil_cryptptr = lutil_crypt;
 #endif
 
+/* KLUDGE:
+ *  chk_fn is NULL iff name is {CLEARTEXT}
+ *     otherwise, things will break
+ */
 struct pw_scheme {
        struct berval name;
        LUTIL_PASSWD_CHK_FUNC *chk_fn;
@@ -147,7 +151,7 @@ static const struct pw_scheme pw_schemes_default[] =
 
 #ifdef SLAPD_CLEARTEXT
        /* pseudo scheme */
-       { {0, "{CLEARTEXT}"},           NULL, hash_clear },
+       { BER_BVC("{CLEARTEXT}"),       NULL, hash_clear },
 #endif
 
        { BER_BVNULL, NULL, NULL }
@@ -209,9 +213,7 @@ static const struct pw_scheme *get_scheme(
        bv.bv_val = (char *) scheme;
 
        for( pws=pw_schemes; pws; pws=pws->next ) {
-               if( bv.bv_len != pws->s.name.bv_len )
-                       continue;
-               if( strncasecmp(bv.bv_val, pws->s.name.bv_val, bv.bv_len ) == 0 ) {
+               if ( ber_bvstrcasecmp(&bv, &pws->s.name ) == 0 ) {
                        return &(pws->s);
                }
        }
@@ -307,8 +309,10 @@ lutil_passwd(
         * didn't recognize? Assume a scheme name is at least 1 character.
         */
        if (( passwd->bv_val[0] == '{' ) &&
-               ( strchr( passwd->bv_val, '}' ) > passwd->bv_val+1 ))
+               ( ber_bvchr( passwd, '}' ) > passwd->bv_val+1 ))
+       {
                return 1;
+       }
        if( is_allowed_scheme("{CLEARTEXT}", schemes ) ) {
                return ( passwd->bv_len == cred->bv_len ) ?
                        memcmp( passwd->bv_val, cred->bv_val, passwd->bv_len )