diff options
author | jsing <> | 2024-05-06 14:36:05 +0000 |
---|---|---|
committer | jsing <> | 2024-05-06 14:36:05 +0000 |
commit | d45b716825a1d5fe9ecacfa6604c73bbbb7271c8 (patch) | |
tree | a4883e721f295435bac767d62c756c1c9462baa8 | |
parent | d8b68bed853f60a20b979d5840f5e7a0e25ea153 (diff) | |
download | openbsd-d45b716825a1d5fe9ecacfa6604c73bbbb7271c8.tar.gz openbsd-d45b716825a1d5fe9ecacfa6604c73bbbb7271c8.tar.bz2 openbsd-d45b716825a1d5fe9ecacfa6604c73bbbb7271c8.zip |
Guard call to contract() from doall_util_fn().
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@
-rw-r--r-- | src/lib/libcrypto/lhash/lhash.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/lib/libcrypto/lhash/lhash.c b/src/lib/libcrypto/lhash/lhash.c index cd69f6fec1..2fb3c4ca59 100644 --- a/src/lib/libcrypto/lhash/lhash.c +++ b/src/lib/libcrypto/lhash/lhash.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: lhash.c,v 1.22 2024/03/02 11:11:11 tb Exp $ */ | 1 | /* $OpenBSD: lhash.c,v 1.23 2024/05/06 14:36:05 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -294,7 +294,9 @@ doall_util_fn(_LHASH *lh, int use_arg, LHASH_DOALL_FN_TYPE func, | |||
294 | 294 | ||
295 | /* Restore down load factor and trigger contraction. */ | 295 | /* Restore down load factor and trigger contraction. */ |
296 | lh->down_load = down_load; | 296 | lh->down_load = down_load; |
297 | contract(lh); | 297 | if ((lh->num_nodes > MIN_NODES) && |
298 | (lh->down_load >= (lh->num_items * LH_LOAD_MULT / lh->num_nodes))) | ||
299 | contract(lh); | ||
298 | } | 300 | } |
299 | 301 | ||
300 | void | 302 | void |