From cf0bc703b3939e79c38c604a4142a53757a0a90e Mon Sep 17 00:00:00 2001 From: Arvid Requate Date: Tue, 21 Aug 2012 19:09:36 +0200 Subject: [PATCH] support for non-ascii in check_password_quality --- lib/util/genrand.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/util/genrand.c b/lib/util/genrand.c index 57884ef..72208be 100644 --- a/lib/util/genrand.c +++ b/lib/util/genrand.c @@ -22,6 +22,7 @@ #include "includes.h" #include "system/filesys.h" #include "../lib/crypto/crypto.h" +#include "lib/util/charset/charset.h" #include "system/locale.h" /** @@ -304,19 +305,23 @@ _PUBLIC_ bool check_password_quality(const char *s) { int has_digit=0, has_capital=0, has_lower=0, has_special=0, has_high=0; const char* reals = s; + struct smb_iconv_handle *ic = get_iconv_handle(); while (*s) { + size_t c_size; + codepoint_t c = next_codepoint_handle(ic, s, &c_size); + if (isdigit((unsigned char)*s)) { has_digit |= 1; - } else if (isupper((unsigned char)*s)) { + } else if (isupper_m(c)) { has_capital |= 1; - } else if (islower((unsigned char)*s)) { + } else if (islower_m(c)) { has_lower |= 1; } else if (isascii((unsigned char)*s)) { has_special |= 1; } else { has_high++; } - s++; + s += c_size; } return ((has_digit + has_lower + has_capital + has_special) >= 3 -- 1.7.10.4