Bugfix in generate random string.
authorphilippe_mingo <philippe_mingo@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 11 Feb 2002 19:36:12 +0000 (19:36 +0000)
committerphilippe_mingo <philippe_mingo@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 11 Feb 2002 19:36:12 +0000 (19:36 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@2419 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/strings.php

index 722cede..e9bac3f 100644 (file)
@@ -539,14 +539,15 @@ function GenerateRandomString($size, $chars, $flags = 0) {
     if (($size < 1) || (strlen($chars) < 1)) {
         return '';
     }
-    
+
     sq_mt_randomize(); /* Initialize the random number generator */
-    
+
     $String = '';
+    $j = strlen( $chars ) - 1;
     while (strlen($String) < $size) {
-        $String .= $chars[mt_rand(0, strlen($chars))];
+        $String .= $chars{mt_rand(0, $j)};
     }
-    
+
     return $String;
 }