]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
mod_unique_id: Follow up to r1892915: Shorter counter race condition yet.
authorYann Ylavic <ylavic@apache.org>
Tue, 7 Sep 2021 01:17:57 +0000 (01:17 +0000)
committerYann Ylavic <ylavic@apache.org>
Tue, 7 Sep 2021 01:17:57 +0000 (01:17 +0000)
* modules/metadata/mod_unique_id.c(gen_unique_id):
  Set the counter in network byte order for uuencoding only, allowing for
  simple cur_unique_id.counter++

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

modules/metadata/mod_unique_id.c

index a25ae3fc9b893307093ee5e3e0cba6ee586446a5..78c4e61bf8a29fa3b6ea3ba25a3248afd1d13a87 100644 (file)
@@ -195,17 +195,15 @@ static const char *gen_unique_id(const request_rec *r)
         unsigned char pad[2];
     } paddedbuf;
     unsigned char *x,*y;
-    unsigned short counter;
     int i,j,k;
 
     memcpy(&new_unique_id.root, &cur_unique_id.root, ROOT_SIZE);
     new_unique_id.stamp = htonl((unsigned int)apr_time_sec(r->request_time));
     new_unique_id.thread_index = htonl((unsigned int)r->connection->id);
-    new_unique_id.counter = cur_unique_id.counter;
+    new_unique_id.counter = cur_unique_id.counter++;
 
-    /* Increment the identifier for the next call */
-    counter = ntohs(new_unique_id.counter) + 1;
-    cur_unique_id.counter = htons(counter);
+    /* Set counter in network byte order for the uuencoded unique id. */
+    new_unique_id.counter = htons(new_unique_id.counter);
 
     /* we'll use a temporal buffer to avoid uuencoding the possible internal
      * paddings of the original structure */