"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/lib/dhcp/libdhcp++.cc" between
kea-1.6.1.tar.gz and kea-1.6.2.tar.gz

About: Kea is a modern DHCPv4 & DHCPv6 Server (potential successor of ISC DHCP).

libdhcp++.cc  (kea-1.6.1):libdhcp++.cc  (kea-1.6.2)
// Copyright (C) 2011-2019 Internet Systems Consortium, Inc. ("ISC") // Copyright (C) 2011-2020 Internet Systems Consortium, Inc. ("ISC")
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include <config.h> #include <config.h>
#include <dhcp/dhcp4.h> #include <dhcp/dhcp4.h>
#include <dhcp/dhcp6.h> #include <dhcp/dhcp6.h>
#include <dhcp/libdhcp++.h> #include <dhcp/libdhcp++.h>
skipping to change at line 475 skipping to change at line 475
options.insert(std::make_pair(opt_type, opt)); options.insert(std::make_pair(opt_type, opt));
} }
offset += opt_len; offset += opt_len;
} }
last_offset = offset; last_offset = offset;
return (last_offset); return (last_offset);
} }
size_t LibDHCP::unpackOptions4(const OptionBuffer& buf, size_t
const std::string& option_space, LibDHCP::unpackOptions4(const OptionBuffer& buf,
isc::dhcp::OptionCollection& options, const std::string& option_space,
std::list<uint16_t>& deferred) { isc::dhcp::OptionCollection& options,
std::list<uint16_t>& deferred,
bool flexible_pad_end) {
size_t offset = 0; size_t offset = 0;
size_t last_offset = 0; size_t last_offset = 0;
// Special case when option_space is dhcp4. // Special case when option_space is dhcp4.
bool space_is_dhcp4 = (option_space == DHCP4_OPTION_SPACE); bool space_is_dhcp4 = (option_space == DHCP4_OPTION_SPACE);
// Get the list of standard option definitions. // Get the list of standard option definitions.
const OptionDefContainerPtr& option_defs = LibDHCP::getOptionDefs(option_spa ce); const OptionDefContainerPtr& option_defs = LibDHCP::getOptionDefs(option_spa ce);
// Runtime option definitions for non standard option space and if // Runtime option definitions for non standard option space and if
// the definition doesn't exist within the standard option definitions. // the definition doesn't exist within the standard option definitions.
const OptionDefContainerPtr& runtime_option_defs = LibDHCP::getRuntimeOption Defs(option_space); const OptionDefContainerPtr& runtime_option_defs = LibDHCP::getRuntimeOption Defs(option_space);
// Get the search indexes #1. It allows to search for option definitions // Get the search indexes #1. It allows to search for option definitions
// using option code. // using option code.
const OptionDefContainerTypeIndex& idx = option_defs->get<1>(); const OptionDefContainerTypeIndex& idx = option_defs->get<1>();
const OptionDefContainerTypeIndex& runtime_idx = runtime_option_defs->get<1> (); const OptionDefContainerTypeIndex& runtime_idx = runtime_option_defs->get<1> ();
// Flexible PAD and END parsing.
bool flex_pad = (flexible_pad_end && (runtime_idx.count(DHO_PAD) == 0));
bool flex_end = (flexible_pad_end && (runtime_idx.count(DHO_END) == 0));
// The buffer being read comprises a set of options, each starting with // The buffer being read comprises a set of options, each starting with
// a one-byte type code and a one-byte length field. // a one-byte type code and a one-byte length field.
while (offset < buf.size()) { while (offset < buf.size()) {
// Save the current offset for backtracking // Save the current offset for backtracking
last_offset = offset; last_offset = offset;
// Get the option type // Get the option type
uint8_t opt_type = buf[offset++]; uint8_t opt_type = buf[offset++];
// DHO_END is a special, one octet long option // DHO_END is a special, one octet long option
if (space_is_dhcp4 && (opt_type == DHO_END)) { // Valid in dhcp4 space or when flexible_pad_end is true and
// there is a sub-option configured for this code.
if ((opt_type == DHO_END) && (space_is_dhcp4 || flex_end)) {
// just return. Don't need to add DHO_END option // just return. Don't need to add DHO_END option
// Don't return offset because it makes this condition // Don't return offset because it makes this condition
// and partial parsing impossible to recognize. // and partial parsing impossible to recognize.
return (last_offset); return (last_offset);
} }
// DHO_PAD is just a padding after DHO_END. Let's continue parsing // DHO_PAD is just a padding after DHO_END. Let's continue parsing
// in case we receive a message without DHO_END. // in case we receive a message without DHO_END.
if (space_is_dhcp4 && (opt_type == DHO_PAD)) { // Valid in dhcp4 space or when flexible_pad_end is true and
// there is a sub-option configured for this code.
if ((opt_type == DHO_PAD) && (space_is_dhcp4 || flex_pad)) {
continue; continue;
} }
if (offset + 1 > buf.size()) { if (offset + 1 > buf.size()) {
// We peeked at the option header of the next option, but // We peeked at the option header of the next option, but
// discovered that it would end up beyond buffer end, so // discovered that it would end up beyond buffer end, so
// the option is truncated. Hence we can't parse // the option is truncated. Hence we can't parse
// it. Therefore we revert back (as if we never parsed it). // it. Therefore we revert back (as if we never parsed it).
// //
// @note it is the responsibility of the caller to throw // @note it is the responsibility of the caller to throw
 End of changes. 5 change blocks. 
7 lines changed or deleted 17 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)