Skip to content

Commit 958f321

Browse files
committed
crypto: exit potentially infinite loop in GetLastIssuedCert if stuck
Fixes: #37757 Refs: #37889
1 parent a90c36e commit 958f321

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/crypto/crypto_common.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,8 +480,17 @@ 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();
487+
483488
// Delete previous cert and continue aggregating issuers.
484489
cert->reset(ca);
490+
491+
X509* value_after_reset = cert->get();
492+
if (value_before_reset == value_after_reset)
493+
break;
485494
}
486495
return MaybeLocal<Object>(issuer_chain);
487496
}

0 commit comments

Comments
 (0)