From bd978e14fcf12f982ad361878f80ece3dbf5aa8c Mon Sep 17 00:00:00 2001 From: Nils Dralle Date: Wed, 31 Mar 2021 16:48:01 +0200 Subject: [PATCH] crypto: more compact solution to detect endless loop --- src/crypto/crypto_common.cc | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/crypto/crypto_common.cc b/src/crypto/crypto_common.cc index a785ca3e2e3415..22aa0f7f692a37 100644 --- a/src/crypto/crypto_common.cc +++ b/src/crypto/crypto_common.cc @@ -480,17 +480,14 @@ MaybeLocal GetLastIssuedCert( return MaybeLocal(); issuer_chain = ca_info; - // Take the value of cert->get() before and after the call to cert->reset() - // in order to compare them and provide a way to exit this loop - // in case it gets stuck - X509* value_before_reset = cert->get(); + // Take the value of cert->get(), compare it with the value of ca + // and provide a way to exit this loop + // in case it gets stuck. + if (cert->get() == ca) + break; // Delete previous cert and continue aggregating issuers. cert->reset(ca); - - X509* value_after_reset = cert->get(); - if (value_before_reset == value_after_reset) - break; } return MaybeLocal(issuer_chain); }