]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
initialize counter with random number
authorStefan Fritsch <sf@apache.org>
Thu, 15 Sep 2011 19:54:37 +0000 (19:54 +0000)
committerStefan Fritsch <sf@apache.org>
Thu, 15 Sep 2011 19:54:37 +0000 (19:54 +0000)
PR: 45110

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1171249 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
modules/metadata/mod_unique_id.c

diff --git a/CHANGES b/CHANGES
index 688981faf09a7ec13a437f620d8b88ee429b9af2..b5c0fa82a0e74639e03f9dc185f8bacb2f54770b 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -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
index 7b67b557c764b9ac3217e425b4356aab62a70e70..b710f7f39a8c4e42dd5a7defce3ceb233eb233ff 100644 (file)
@@ -221,7 +221,6 @@ static int unique_id_global_init(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *pt
 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_pool_t *p, server_rec *s)
      * 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_pool_t *p, server_rec *s)
      * 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