httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pque...@apache.org
Subject svn commit: r629159 - /httpd/httpd/trunk/support/htpasswd.c
Date Tue, 19 Feb 2008 16:55:51 GMT
Author: pquerna
Date: Tue Feb 19 08:55:47 2008
New Revision: 629159

URL: http://svn.apache.org/viewvc?rev=629159&view=rev
Log:
Improve salt string generation.

PR: 31440

Modified:
    httpd/httpd/trunk/support/htpasswd.c

Modified: httpd/httpd/trunk/support/htpasswd.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/support/htpasswd.c?rev=629159&r1=629158&r2=629159&view=diff
==============================================================================
--- httpd/httpd/trunk/support/htpasswd.c (original)
+++ httpd/httpd/trunk/support/htpasswd.c Tue Feb 19 08:55:47 2008
@@ -115,6 +115,18 @@
     }
 }
 
+static void generate_salt(char *s, size_t size)
+{
+    static unsigned char tbl[] = 
+        "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+    size_t i;
+    for (i = 0; i < size; ++i) {
+        int idx = (int) (64.0 * rand() / (RAND_MAX + 1.0));
+        s[i] = tbl[idx];
+    }
+}
+
+
 static void putline(apr_file_t *f, const char *l)
 {
     apr_file_puts(l, f);
@@ -163,7 +175,7 @@
 
     case ALG_APMD5:
         (void) srand((int) time((time_t *) NULL));
-        to64(&salt[0], rand(), 8);
+        generate_salt(&salt[0], 8);
         salt[8] = '\0';
 
         apr_md5_encode((const char *)pw, (const char *)salt,



Mime
View raw message