]> git.sur5r.net Git - openldap/blobdiff - libraries/liblutil/passwd.c
from jon@symas.com - misc cleanup
[openldap] / libraries / liblutil / passwd.c
index 5a04acfdccbae1ecd80f1eb71be6331ec55728b3..739c833bc6db2fa7883084f7e1b2afa8415556b3 100644 (file)
@@ -66,7 +66,7 @@ static const unsigned char crypt64[] =
        "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890./";
 
 #ifdef SLAPD_CRYPT
-static const char *salt_format = NULL;
+static char *salt_format = NULL;
 #endif
 
 struct pw_scheme;
@@ -373,6 +373,8 @@ struct berval * lutil_passwd_hash(
        return (sc->hash_fn)( sc, passwd );
 }
 
+/* pw_string is only called when SLAPD_LMHASH or SLAPD_CRYPT is defined */
+#if defined(SLAPD_LMHASH) || defined(SLAPD_CRYPT)
 static struct berval * pw_string(
        const struct pw_scheme *sc,
        const struct berval *passwd )
@@ -394,6 +396,7 @@ static struct berval * pw_string(
        pw->bv_val[pw->bv_len] = '\0';
        return pw;
 }
+#endif /* SLAPD_LMHASH || SLAPD_CRYPT */
 
 static struct berval * pw_string64(
        const struct pw_scheme *sc,
@@ -1239,15 +1242,9 @@ static struct berval *hash_crypt(
 int lutil_salt_format(const char *format)
 {
 #ifdef SLAPD_CRYPT
-       if (format) {
-               if (salt_format)
-                       free(salt_format);
-               salt_format = strdup(format);
-       } else {  // unset if they pass in NULL
-               if (salt_format)
-                       free(salt_format);
-               salt_format = NULL;
-       }
+       free( salt_format );
+
+       salt_format = format != NULL ? strdup( format ) : NULL;
 #endif
 
        return 0;