Skip to content

Commit

Permalink
crypto: exit potentially infinite loop in GetLastIssuedCert if stuck
Browse files Browse the repository at this point in the history
Fixes: #37757
Refs: #37889
  • Loading branch information
nils91 committed Mar 31, 2021
1 parent 1ad4041 commit f0020fb
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/crypto/crypto_common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,17 @@ MaybeLocal<Object> GetLastIssuedCert(
return MaybeLocal<Object>();
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();

// 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<Object>(issuer_chain);
}
Expand Down

0 comments on commit f0020fb

Please sign in to comment.