From: Bernd Edlinger Date: Wed, 20 Sep 2023 13:45:56 +0000 (+0200) Subject: Fix error handling in lhash contract X-Git-Tag: openssl-3.1.4~65 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1ae2bb26d3beb9de6fa5edfa198cf86e138c00d8;p=thirdparty%2Fopenssl.git Fix error handling in lhash contract When the realloc fails in contract, this not a fatal error, since the memory is only shrinked. It is also no option to exit the function at this point, since that would leave the hash table in an inconsistent state. Reviewed-by: Tomas Mraz Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/22154) (cherry picked from commit 5fbfd641aeebdf4b29a0749e13a79a1e59502878) --- diff --git a/crypto/lhash/lhash.c b/crypto/lhash/lhash.c index c319a44c7b2..8623bcb395e 100644 --- a/crypto/lhash/lhash.c +++ b/crypto/lhash/lhash.c @@ -266,12 +266,12 @@ static void contract(OPENSSL_LHASH *lh) if (n == NULL) { /* fputs("realloc error in lhash",stderr); */ lh->error++; - return; + } else { + lh->b = n; } lh->num_alloc_nodes /= 2; lh->pmax /= 2; lh->p = lh->pmax - 1; - lh->b = n; } else lh->p--;