From: Ashish Agarwal Date: April 18 2012 1:11pm Subject: bzr push into mysql-trunk branch (ashish.y.agarwal:3875 to 3876) List-Archive: http://lists.mysql.com/commits/143527 Message-Id: <201204181311.q3IDBc4G025450@acsmt358.oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 3876 Ashish Agarwal 2012-04-18 wl2739: Auditing Password Security Some performance issue. modified: plugin/password_validation/validate_password.cc 3875 Ashish Agarwal 2012-04-18 WL#2739: Still some problem exsists with compilation in windows. Patch to solve it. modified: plugin/password_validation/validate_password.cc === modified file 'plugin/password_validation/validate_password.cc' --- a/plugin/password_validation/validate_password.cc 2012-04-18 06:39:26 +0000 +++ b/plugin/password_validation/validate_password.cc 2012-04-18 13:09:16 +0000 @@ -15,7 +15,8 @@ #include #include -#include +#include +#include #include #include "m_ctype.h" #include "sql_plugin.h" @@ -25,8 +26,8 @@ #define PASSWORD_STRENGTH_MEDIUM 2 #define PASSWORD_STRENGTH_STRONG 3 -typedef std::map maptype; -maptype dictionary_words; +typedef std::set settype; +settype dictionary_words; static uint validate_password_length; static uint validate_password_numbers; @@ -70,7 +71,7 @@ static int validate_password_policy(cons if (policy == PASSWORD_STRENGTH_MEDIUM) return 1; std::string str= password; - maptype::iterator itr; + settype::iterator itr; itr= dictionary_words.find(str); if (itr == dictionary_words.end()) return 1; @@ -113,9 +114,6 @@ static struct st_mysql_validate_password static int validate_password_init(void *arg __attribute__((unused))) { - MYSQL_FILE *fp; - char buff[128]; /* maximum length of word stored in dictionary file */ - uint count= 0; char *dictionary_file; char default_dictionary_file[FN_REFLEN]; fn_format(default_dictionary_file, "dictionary.txt", opt_plugin_dir_ptr, @@ -124,18 +122,12 @@ static int validate_password_init(void * validate_password_dictionary_file : default_dictionary_file); - if (!(fp= mysql_file_fopen - (0, dictionary_file, O_RDONLY, MYF(0)))) - return 1; - while (mysql_file_fgets(buff, sizeof(buff) - 1, fp)) - { - buff[strlen(buff) - 1]= '\0'; - std::string str= (const char *) buff; - dictionary_words.insert(std::pair(str, count)); - count++; - } - if (mysql_file_fclose(fp, MYF(0))) + std::ifstream dictionary_stream(dictionary_file); + std::string words; + if (!dictionary_stream) return 1; + while (std::getline(dictionary_stream, words)) + dictionary_words.insert(words); return 0; } No bundle (reason: useless for push emails).