Skip to content

Commit

Permalink
[#3193] fixed double free when using botan
Browse files Browse the repository at this point in the history
  • Loading branch information
Razvan Becheriu committed Feb 23, 2024
1 parent 6bfbdab commit bc69558
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 8 deletions.
2 changes: 0 additions & 2 deletions src/lib/cryptolink/botan_link.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ CryptoLink::initialize(CryptoLink& c) {
isc_throw(InitializationError, "Botan error: " << ex.what());
}
}
// A not yet fixed bug makes RNG to be destroyed after memory pool...
atexit([]{ getCryptoLink().getRNG().reset(); });
}

std::string
Expand Down
3 changes: 1 addition & 2 deletions src/lib/cryptolink/crypto_rng.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ RNG::~RNG() {
}

std::vector<uint8_t>
random(size_t len)
{
random(size_t len) {
RNGPtr rng(CryptoLink::getCryptoLink().getRNG());
return (rng->random(len));
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/cryptolink/crypto_rng.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class RNG : private boost::noncopyable {
virtual std::vector<uint8_t> random(size_t len) = 0;

private:
friend RNGPtr& CryptoLink::getRNG();
friend RNGPtr const& CryptoLink::getRNG() const;
};

/// \brief Generate random value.
Expand Down
4 changes: 2 additions & 2 deletions src/lib/cryptolink/cryptolink.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ CryptoLink::createHMAC(const void* secret, size_t secret_len,
return (new HMAC(secret, secret_len, hash_algorithm));
}

RNGPtr&
CryptoLink::getRNG() {
RNGPtr const&
CryptoLink::getRNG() const {
return (rng_);
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/cryptolink/cryptolink.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class CryptoLink : private boost::noncopyable {
/// in a derived class
/// \exception LibraryError if there was any unexpected exception
/// in the underlying library
virtual RNGPtr& getRNG();
virtual RNGPtr const& getRNG() const;

private:
/// \brief Initialize the library
Expand Down

0 comments on commit bc69558

Please sign in to comment.