From: Yann Ylavic Date: Tue, 7 Sep 2021 01:17:57 +0000 (+0000) Subject: mod_unique_id: Follow up to r1892915: Shorter counter race condition yet. X-Git-Tag: 2.5.0-alpha2-ci-test-only~831 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=13d3c1926aa73acc85a36c42709070fd2ebb291a;p=thirdparty%2Fapache%2Fhttpd.git mod_unique_id: Follow up to r1892915: Shorter counter race condition yet. * 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 --- diff --git a/modules/metadata/mod_unique_id.c b/modules/metadata/mod_unique_id.c index a25ae3fc9b8..78c4e61bf8a 100644 --- a/modules/metadata/mod_unique_id.c +++ b/modules/metadata/mod_unique_id.c @@ -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 */