Browse Source

Revert "Avoid potential use-after-free bug"

This reverts commit 5d1c2b257ac9b5e8d998b188e3aa4a40f97d84b8.

The segfault was actually caused by a version mismatch between Kea and
this hook, the code should be safe as it was.
Baptiste Jonglez 7 years ago
parent
commit
13bc08c9cd
1 changed files with 2 additions and 4 deletions
  1. 2 4
      src/callouts.cc

+ 2 - 4
src/callouts.cc

@@ -74,8 +74,7 @@ void extract_subnet4(std::vector<std::string>& env, const Subnet4Ptr subnet)
 {
     env.push_back("KEA_SUBNET4=" + subnet->toText());
     std::pair<isc::asiolink::IOAddress, uint8_t> prefix = subnet->get();
-    /* Copy string to avoid use-after-free when we return from this function */
-    env.push_back("KEA_SUBNET4_PREFIX=" + std::string(prefix.first.toText()));
+    env.push_back("KEA_SUBNET4_PREFIX=" + prefix.first.toText());
     env.push_back("KEA_SUBNET4_PREFIXLEN=" + std::to_string(prefix.second));
 }
 
@@ -83,8 +82,7 @@ void extract_subnet6(std::vector<std::string>& env, const Subnet6Ptr subnet)
 {
     env.push_back("KEA_SUBNET6=" + subnet->toText());
     std::pair<isc::asiolink::IOAddress, uint8_t> prefix = subnet->get();
-    /* Copy string to avoid use-after-free when we return from this function */
-    env.push_back("KEA_SUBNET6_PREFIX=" + std::string(prefix.first.toText()));
+    env.push_back("KEA_SUBNET6_PREFIX=" + prefix.first.toText());
     env.push_back("KEA_SUBNET6_PREFIXLEN=" + std::to_string(prefix.second));
 }