]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR server: Restrict dynamic cookie check to the same proxy.
authorOlivier Houchard <cognet@ci0.org>
Tue, 4 Apr 2017 20:10:36 +0000 (22:10 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 10 Apr 2017 13:20:11 +0000 (15:20 +0200)
Each time we generate a dynamic cookie, we try to make sure the same
cookie hasn't been generated for another server, it's very unlikely, but
it may happen.
We only have to check that for the servers in the same proxy, no, need to
check in others, plus the code was buggy and would always check in the
first proxy of the proxy list.

src/server.c

index 23343d86f6c9fe50257c7c0cfe25247ccc968051..6070de93cacb7ff7bfe8c3ef24c42ea1fecc1f08 100644 (file)
@@ -135,18 +135,17 @@ void srv_set_dyncookie(struct server *s)
         * Check that we did not get a hash collision.
         * Unlikely, but it can happen.
         */
-       for (p = proxy; p != NULL; p = p->next)
-               for (tmpserv = proxy->srv; tmpserv != NULL;
-                   tmpserv = tmpserv->next) {
-                       if (tmpserv == s)
-                               continue;
-                       if (tmpserv->cookie &&
-                           strcmp(tmpserv->cookie, s->cookie) == 0) {
-                               Warning("We generated two equal cookies for two different servers.\n"
-                                   "Please change the secret key for '%s'.\n",
-                                   s->proxy->id);
-                       }
+       for (tmpserv = p->srv; tmpserv != NULL;
+           tmpserv = tmpserv->next) {
+               if (tmpserv == s)
+                       continue;
+               if (tmpserv->cookie &&
+                   strcmp(tmpserv->cookie, s->cookie) == 0) {
+                       Warning("We generated two equal cookies for two different servers.\n"
+                           "Please change the secret key for '%s'.\n",
+                           s->proxy->id);
                }
+       }
 }
 
 /*