Skip to content

Commit bd978e1

Browse files
committed
crypto: more compact solution to detect endless loop
1 parent 958f321 commit bd978e1

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/crypto/crypto_common.cc

+5-8
Original file line numberDiff line numberDiff line change
@@ -480,17 +480,14 @@ MaybeLocal<Object> GetLastIssuedCert(
480480
return MaybeLocal<Object>();
481481
issuer_chain = ca_info;
482482

483-
// Take the value of cert->get() before and after the call to cert->reset()
484-
// in order to compare them and provide a way to exit this loop
485-
// in case it gets stuck
486-
X509* value_before_reset = cert->get();
483+
// Take the value of cert->get(), compare it with the value of ca
484+
// and provide a way to exit this loop
485+
// in case it gets stuck.
486+
if (cert->get() == ca)
487+
break;
487488

488489
// Delete previous cert and continue aggregating issuers.
489490
cert->reset(ca);
490-
491-
X509* value_after_reset = cert->get();
492-
if (value_before_reset == value_after_reset)
493-
break;
494491
}
495492
return MaybeLocal<Object>(issuer_chain);
496493
}

0 commit comments

Comments
 (0)