httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s.@apache.org
Subject svn commit: r1171249 - in /httpd/httpd/trunk: CHANGES modules/metadata/mod_unique_id.c
Date Thu, 15 Sep 2011 19:54:37 GMT
Author: sf
Date: Thu Sep 15 19:54:37 2011
New Revision: 1171249

URL: http://svn.apache.org/viewvc?rev=1171249&view=rev
Log:
initialize counter with random number

PR: 45110

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/modules/metadata/mod_unique_id.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1171249&r1=1171248&r2=1171249&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Thu Sep 15 19:54:37 2011
@@ -12,6 +12,9 @@ Changes with Apache 2.3.15
      PR 51714. [Stefan Fritsch, Jim Jagielski, Ruediger Pluem, Eric Covener,
      <lowprio20 gmail.com>]
 
+  *) mod_unique_id: Use random number generator to initialize counter.
+     PR 45110. [Stefan Fritsch]
+
   *) core: Add convenience API for apr_random. [Stefan Fritsch]
 
   *) core: Add MaxRangeOverlaps and MaxRangeReversals directives to control

Modified: httpd/httpd/trunk/modules/metadata/mod_unique_id.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/metadata/mod_unique_id.c?rev=1171249&r1=1171248&r2=1171249&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/metadata/mod_unique_id.c (original)
+++ httpd/httpd/trunk/modules/metadata/mod_unique_id.c Thu Sep 15 19:54:37 2011
@@ -221,7 +221,6 @@ static int unique_id_global_init(apr_poo
 static void unique_id_child_init(apr_pool_t *p, server_rec *s)
 {
     pid_t pid;
-    apr_time_t tv;
 
     /*
      * Note that we use the pid because it's possible that on the same
@@ -253,11 +252,8 @@ static void unique_id_child_init(apr_poo
      * against restart problems, and a little less protection against a clock
      * going backwards in time.
      */
-    tv = apr_time_now();
-    /* Some systems have very low variance on the low end of their system
-     * counter, defend against that.
-     */
-    cur_unique_id.counter = (unsigned short)(apr_time_usec(tv) / 10);
+    ap_random_insecure_bytes(&cur_unique_id.counter,
+                             sizeof(cur_unique_id.counter));
 
     /*
      * We must always use network ordering for these bytes, so that
@@ -265,7 +261,6 @@ static void unique_id_child_init(apr_poo
      * orderings.  Note in_addr is already in network order.
      */
     cur_unique_id.pid = htonl(cur_unique_id.pid);
-    cur_unique_id.counter = htons(cur_unique_id.counter);
 }
 
 /* NOTE: This is *NOT* the same encoding used by base64encode ... the last two



Mime
View raw message