]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[master] Merge branch 'trac4498'
authorMarcin Siodelski <marcin@isc.org>
Fri, 10 Jun 2016 14:22:56 +0000 (16:22 +0200)
committerMarcin Siodelski <marcin@isc.org>
Fri, 10 Jun 2016 14:22:56 +0000 (16:22 +0200)
1  2 
src/bin/dhcp4/dhcp4_srv.cc
src/bin/dhcp6/dhcp6_srv.cc
src/lib/dhcp/libdhcp++.cc
src/lib/dhcp/libdhcp++.h
src/lib/dhcp/pkt4.cc

Simple merge
Simple merge
index eeebcf5da7f373fb82bd1d68832a744c87faf5b7,6f4cdc22d8175c9cec6cd939df8bf2571e4e5467..116c61dc2671837c27316cb602b36623e846cdd9
@@@ -845,37 -853,18 +855,44 @@@ LibDHCP::initVendorOptsIsc6() 
      initOptionSpace(vendor6_defs_[ENTERPRISE_ID_ISC], ISC_V6_DEFS, ISC_V6_DEFS_SIZE);
  }
  
- void initOptionSpace(OptionDefContainer& defs,
 +uint32_t
 +LibDHCP::optionSpaceToVendorId(const std::string& option_space) {
 +    // 8 is a minimal length of "vendor-X" format
 +    if ((option_space.size() < 8) || (option_space.substr(0,7) != "vendor-")) {
 +        return (0);
 +    }
 +
 +    int64_t check;
 +    try {
 +        // text after "vendor-", supposedly numbers only
 +        std::string x = option_space.substr(7);
 +
 +        check = boost::lexical_cast<int64_t>(x);
 +
 +    } catch (const boost::bad_lexical_cast &) {
 +        return (0);
 +    }
 +
 +    if ((check < 0) || (check > std::numeric_limits<uint32_t>::max())) {
 +        return (0);
 +    }
 +
 +    // value is small enough to fit
 +    return (static_cast<uint32_t>(check));
 +}
 +
+ void initOptionSpace(OptionDefContainerPtr& defs,
                       const OptionDefParams* params,
                       size_t params_size) {
-     defs.clear();
+     // Container holding vendor options is typically not initialized, as it
+     // is held in map of null pointers. We need to initialize here in this
+     // case.
+     if (!defs) {
+         defs.reset(new OptionDefContainer());
+     } else {
+         defs->clear();
+     }
  
      for (size_t i = 0; i < params_size; ++i) {
          std::string encapsulates(params[i].encapsulates);
Simple merge
Simple merge