Skip to content

Commit 59e8bdd

Browse files
committed
fix: most_connections_available check had integer overflow
1 parent ac2b3f7 commit 59e8bdd

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/vmod_dynamic.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ static struct dynamic_ref *
256256
dom_find_leastconn(VRT_CTX, struct dynamic_domain *dom)
257257
{
258258
struct dynamic_ref *next, *best_next;
259-
unsigned most_connections_available;
259+
int most_connections_available;
260260

261261
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
262262
CHECK_OBJ_NOTNULL(dom, DYNAMIC_DOMAIN_MAGIC);
@@ -268,7 +268,7 @@ dom_find_leastconn(VRT_CTX, struct dynamic_domain *dom)
268268

269269
next = VTAILQ_FIRST(&dom->refs);
270270
best_next = NULL;
271-
most_connections_available = 0;
271+
most_connections_available = INT_MIN;
272272

273273
do {
274274
CHECK_OBJ_ORNULL(next, DYNAMIC_REF_MAGIC);
@@ -280,7 +280,7 @@ dom_find_leastconn(VRT_CTX, struct dynamic_domain *dom)
280280
if (next->dir != creating && next->dir != NULL && VRT_Healthy(ctx, next->dir, NULL)) {
281281
if (VALID_OBJ((struct backend *)next->dir->priv, BACKEND_MAGIC)) {
282282
struct backend *be;
283-
unsigned connections_available;
283+
int connections_available;
284284

285285
CAST_OBJ_NOTNULL(be, next->dir->priv, BACKEND_MAGIC);
286286
connections_available = be->max_connections > 0 ? be->max_connections - be->n_conn : - be->n_conn;

0 commit comments

Comments
 (0)