List:Commits« Previous MessageNext Message »
From:Ashish Agarwal Date:April 18 2012 1:11pm
Subject:bzr push into mysql-trunk branch (ashish.y.agarwal:3875 to 3876)
View as plain text  
 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 <string>
 #include <mysql/plugin_validate_password.h>
-#include <map>
+#include <set>
+#include <fstream>
 #include <mysql/psi/mysql_file.h>
 #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<std::string, int> maptype;
-maptype dictionary_words;
+typedef std::set<std::string> 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<std::string, int>(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).
Thread
bzr push into mysql-trunk branch (ashish.y.agarwal:3875 to 3876) Ashish Agarwal20 Apr