Skip to content

Commit

Permalink
Guard call to contract() from doall_util_fn().
Browse files Browse the repository at this point in the history
It is not safe to unconditionally call contract() - when called repeatedly
it will shrink the bucket array to zero and then attempt to access that
allocation on the next call. Use the same guard that is used in
lh_delete().

Issue found when investigating haproxy crashes reported by wizard-it on
GitHub.

ok tb@
  • Loading branch information
4a6f656c committed May 6, 2024
1 parent 58a6500 commit 7b25026
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/libcrypto/lhash/lhash.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: lhash.c,v 1.22 2024/03/02 11:11:11 tb Exp $ */
/* $OpenBSD: lhash.c,v 1.23 2024/05/06 14:36:05 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
Expand Down Expand Up @@ -294,7 +294,9 @@ doall_util_fn(_LHASH *lh, int use_arg, LHASH_DOALL_FN_TYPE func,

/* Restore down load factor and trigger contraction. */
lh->down_load = down_load;
contract(lh);
if ((lh->num_nodes > MIN_NODES) &&
(lh->down_load >= (lh->num_items * LH_LOAD_MULT / lh->num_nodes)))
contract(lh);
}

void
Expand Down

0 comments on commit 7b25026

Please sign in to comment.