]> git.sur5r.net Git - openldap/commitdiff
Fix get_scheme to check length of scheme name
authorHoward Chu <hyc@openldap.org>
Fri, 8 Jul 2005 05:46:08 +0000 (05:46 +0000)
committerHoward Chu <hyc@openldap.org>
Fri, 8 Jul 2005 05:46:08 +0000 (05:46 +0000)
libraries/liblutil/passwd.c

index 5460b0376a9226050de5691404c1f206ca9df835..7512dff6d02bc56e93807610742ad0f38cb96dca 100644 (file)
@@ -197,11 +197,21 @@ static const struct pw_scheme *get_scheme(
        const char* scheme )
 {
        struct pw_slist *pws;
+       struct berval bv;
 
        if (!pw_inited) lutil_passwd_init();
 
+       bv.bv_val = strchr( scheme, '}' );
+       if ( !bv.bv_val )
+               return NULL;
+
+       bv.bv_len = bv.bv_val - scheme + 1;
+       bv.bv_val = scheme;
+
        for( pws=pw_schemes; pws; pws=pws->next ) {
-               if( strcasecmp(scheme, pws->s.name.bv_val ) == 0 ) {
+               if( bv.bv_len != pws->s.name.bv_len )
+                       continue;
+               if( strncasecmp(bv.bv_val, pws->s.name.bv_val, bv.bv_len ) == 0 ) {
                        return &(pws->s);
                }
        }