From: Francis Dupont Date: Fri, 31 Jul 2020 22:55:21 +0000 (+0200) Subject: [#749] Converted assert to throw outside dns lib X-Git-Tag: Kea-1.8.0~73 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a48b579bf5e5952653e3a1bfff846c346f7ffc15;p=thirdparty%2Fkea.git [#749] Converted assert to throw outside dns lib --- diff --git a/src/bin/d2/d2_update_message.cc b/src/bin/d2/d2_update_message.cc index 7eb5ab813a..115663fa80 100644 --- a/src/bin/d2/d2_update_message.cc +++ b/src/bin/d2/d2_update_message.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2015,2017 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2020 Internet Systems Consortium, Inc. ("ISC") // // 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 @@ -152,7 +152,9 @@ D2UpdateMessage::fromWire(const void* received_data, size_t bytes_received, // If the Zone counter is greater than 0 (which we have checked) // there must be a valid Question pointer stored in the message_ // object. If there isn't, it is a programming error. - assert(question); + if (!question) { + isc_throw(isc::Unexpected, "question is null?!"); + } zone_.reset(new D2Zone(question->getName(), question->getClass())); } else { @@ -226,4 +228,3 @@ D2UpdateMessage::validateResponse() const { } // namespace d2 } // namespace isc - diff --git a/src/lib/asiodns/io_fetch.cc b/src/lib/asiodns/io_fetch.cc index d5405c518b..5ad10dfdb7 100644 --- a/src/lib/asiodns/io_fetch.cc +++ b/src/lib/asiodns/io_fetch.cc @@ -394,10 +394,12 @@ IOFetch::stop(Result result) { void IOFetch::logIOFailure(boost::system::error_code ec) { // Should only get here with a known error code. - assert((data_->origin == ASIODNS_OPEN_SOCKET) || - (data_->origin == ASIODNS_SEND_DATA) || - (data_->origin == ASIODNS_READ_DATA) || - (data_->origin == ASIODNS_UNKNOWN_ORIGIN)); + if ((data_->origin != ASIODNS_OPEN_SOCKET) && + (data_->origin != ASIODNS_SEND_DATA) && + (data_->origin != ASIODNS_READ_DATA) && + (data_->origin != ASIODNS_UNKNOWN_ORIGIN)) { + isc_throw(isc::Unexpected, "impossible error code " << data_->origin); + } LOG_ERROR(logger, data_->origin).arg(ec.value()). arg((data_->remote_snd->getProtocol() == IPPROTO_TCP) ? diff --git a/src/lib/asiolink/tcp_socket.h b/src/lib/asiolink/tcp_socket.h index b98907a17a..137b828385 100644 --- a/src/lib/asiolink/tcp_socket.h +++ b/src/lib/asiolink/tcp_socket.h @@ -16,7 +16,6 @@ #include // for some IPC/network system calls #include -#include #include #include @@ -29,6 +28,8 @@ #include #include +#include + namespace isc { namespace asiolink { @@ -299,7 +300,7 @@ TCPSocket::open(const IOEndpoint* endpoint, C& callback) { // IOEndpoint is the base class of UDPEndpoint and TCPEndpoint, it does not // contain a method for getting at the underlying endpoint type - that is in /// the derived class and the two classes differ on return type. - assert(endpoint->getProtocol() == IPPROTO_TCP); + isc_throw_assert(endpoint->getProtocol() == IPPROTO_TCP); const TCPEndpoint* tcp_endpoint = static_cast(endpoint); @@ -381,7 +382,7 @@ TCPSocket::asyncReceive(void* data, size_t length, size_t offset, // does not contain a method for getting at the underlying endpoint // type - that is in the derived class and the two classes differ on // return type. - assert(endpoint->getProtocol() == IPPROTO_TCP); + isc_throw_assert(endpoint->getProtocol() == IPPROTO_TCP); TCPEndpoint* tcp_endpoint = static_cast(endpoint); // Write the endpoint details from the communications link. Ideally diff --git a/src/lib/asiolink/udp_socket.h b/src/lib/asiolink/udp_socket.h index 796abaf6c2..afb742608b 100644 --- a/src/lib/asiolink/udp_socket.h +++ b/src/lib/asiolink/udp_socket.h @@ -1,4 +1,4 @@ -// Copyright (C) 2011-2018 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 // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -22,6 +22,8 @@ #include #include +#include + namespace isc { namespace asiolink { @@ -228,7 +230,7 @@ UDPSocket::asyncSend(const void* data, size_t length, // does not contain a method for getting at the underlying endpoint // type - that is in the derived class and the two classes differ on // return type. - assert(endpoint->getProtocol() == IPPROTO_UDP); + isc_throw_assert(endpoint->getProtocol() == IPPROTO_UDP); const UDPEndpoint* udp_endpoint = static_cast(endpoint); @@ -251,7 +253,7 @@ UDPSocket::asyncReceive(void* data, size_t length, size_t offset, if (isopen_) { // Upconvert the endpoint again. - assert(endpoint->getProtocol() == IPPROTO_UDP); + isc_throw_assert(endpoint->getProtocol() == IPPROTO_UDP); UDPEndpoint* udp_endpoint = static_cast(endpoint); // Ensure we can write into the buffer diff --git a/src/lib/dhcp/libdhcp++.cc b/src/lib/dhcp/libdhcp++.cc index 6a6ba1344b..6c417d24ce 100644 --- a/src/lib/dhcp/libdhcp++.cc +++ b/src/lib/dhcp/libdhcp++.cc @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -433,7 +434,7 @@ LibDHCP::unpackOptions6(const OptionBuffer& buf, // The option definition has been found. Use it to create // the option instance from the provided buffer chunk. const OptionDefinitionPtr& def = *(range.first); - assert(def); + isc_throw_assert(def); opt = def->optionFactory(Option::V6, opt_type, buf.begin() + offset, buf.begin() + offset + opt_len); @@ -586,7 +587,7 @@ LibDHCP::unpackOptions4(const OptionBuffer& buf, // The option definition has been found. Use it to create // the option instance from the provided buffer chunk. const OptionDefinitionPtr& def = *(range.first); - assert(def); + isc_throw_assert(def); opt = def->optionFactory(Option::V4, opt_type, buf.begin() + offset, buf.begin() + offset + opt_len); @@ -675,7 +676,7 @@ LibDHCP::unpackVendorOptions6(const uint32_t vendor_id, // The option definition has been found. Use it to create // the option instance from the provided buffer chunk. const OptionDefinitionPtr& def = *(range.first); - assert(def); + isc_throw_assert(def); opt = def->optionFactory(Option::V6, opt_type, buf.begin() + offset, buf.begin() + offset + opt_len); @@ -786,7 +787,7 @@ LibDHCP::unpackVendorOptions4(const uint32_t vendor_id, const OptionBuffer& buf, // The option definition has been found. Use it to create // the option instance from the provided buffer chunk. const OptionDefinitionPtr& def = *(range.first); - assert(def); + isc_throw_assert(def); opt = def->optionFactory(Option::V4, opt_type, buf.begin() + offset, buf.begin() + offset + opt_len); diff --git a/src/lib/dhcp/option_custom.cc b/src/lib/dhcp/option_custom.cc index ac487f085d..dfa22dfec1 100644 --- a/src/lib/dhcp/option_custom.cc +++ b/src/lib/dhcp/option_custom.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2012-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2012-2020 Internet Systems Consortium, Inc. ("ISC") // // 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 @@ -8,6 +8,7 @@ #include #include #include +#include #include using namespace isc::asiolink; @@ -316,7 +317,7 @@ OptionCustom::createBuffers(const OptionBuffer& data_buf) { // Code copied from the standard array case size_t data_size = bufferLength(fields.back(), true, data, data_buf.end()); - assert(data_size > 0); + isc_throw_assert(data_size > 0); if (std::distance(data, data_buf.end()) < data_size) { break; } @@ -355,7 +356,7 @@ OptionCustom::createBuffers(const OptionBuffer& data_buf) { // etc. This is because OptionDefinition::validate function should // have checked this already. Thus data_size must be greater than // zero. - assert(data_size > 0); + isc_throw_assert(data_size > 0); // Get chunks of data and store as a collection of buffers. // Truncate any remaining part which length is not divisible by // data_size. Note that it is ok to truncate the data if and only diff --git a/src/lib/dhcp/option_custom.h b/src/lib/dhcp/option_custom.h index 1dcdc00264..73be64efe6 100644 --- a/src/lib/dhcp/option_custom.h +++ b/src/lib/dhcp/option_custom.h @@ -1,4 +1,4 @@ -// Copyright (C) 2012-2017 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2012-2020 Internet Systems Consortium, Inc. ("ISC") // // 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 @@ -10,6 +10,7 @@ #include #include #include +#include #include namespace isc { @@ -256,7 +257,7 @@ public: checkDataType(index); // When we created the buffer we have checked that it has a // valid size so this condition here should be always fulfilled. - assert(buffers_[index].size() == OptionDataTypeTraits::len); + isc_throw_assert(buffers_[index].size() == OptionDataTypeTraits::len); // Read an integer value. return (OptionDataTypeUtil::readInt(buffers_[index])); } @@ -490,7 +491,7 @@ OptionCustom::checkDataType(const uint32_t index) const { // When we initialized buffers we have already checked that // the number of these buffers is equal to number of option // fields in the record so the condition below should be met. - assert(index < record_fields.size()); + isc_throw_assert(index < record_fields.size()); // Get the data type to be returned. data_type = record_fields[index]; } diff --git a/src/lib/dhcp/pkt_filter_inet6.cc b/src/lib/dhcp/pkt_filter_inet6.cc index 9b92bb9b75..20d682cfbe 100644 --- a/src/lib/dhcp/pkt_filter_inet6.cc +++ b/src/lib/dhcp/pkt_filter_inet6.cc @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -305,7 +306,7 @@ PktFilterInet6::send(const Iface&, uint16_t sockfd, const Pkt6Ptr& pkt) { // CMSG_FIRSTHDR() is coded to return NULL as a possibility. The // following assertion should never fail, but if it did and you came // here, fix the code. :) - assert(cmsg != NULL); + isc_throw_assert(cmsg != NULL); cmsg->cmsg_level = IPPROTO_IPV6; cmsg->cmsg_type = IPV6_PKTINFO; diff --git a/src/lib/log/logger_manager_impl.cc b/src/lib/log/logger_manager_impl.cc index e7cc9fe339..e8e4bfd076 100644 --- a/src/lib/log/logger_manager_impl.cc +++ b/src/lib/log/logger_manager_impl.cc @@ -1,4 +1,4 @@ -// 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 // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -28,6 +28,8 @@ #include #include +#include + #include using namespace std; @@ -275,7 +277,7 @@ void LoggerManagerImpl::flushBufferAppenders() { for (it = copy.begin(); it != copy.end(); ++it) { internal::BufferAppender* app = dynamic_cast(it->get()); - assert(app != NULL); + isc_throw_assert(app); app->flush(); } } diff --git a/src/lib/log/message_reader.cc b/src/lib/log/message_reader.cc index 9159304582..f5b0d3907c 100644 --- a/src/lib/log/message_reader.cc +++ b/src/lib/log/message_reader.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2011-2015 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 // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -6,7 +6,6 @@ #include -#include #include #include #include @@ -14,6 +13,7 @@ #include #include +#include #include #include #include @@ -121,7 +121,7 @@ void MessageReader::parsePrefix(const vector& tokens) { // Should not get here unless there is something in the tokens array. - assert(!tokens.empty()); + isc_throw_assert(!tokens.empty()); // Process $PREFIX. With no arguments, the prefix is set to the empty // string. One argument sets the prefix to the to its value and more than @@ -219,7 +219,7 @@ MessageReader::parseMessage(const std::string& text, MessageReader::Mode mode) { // The line passed should be at least one character long and start with the // message introducer (else we should not have got here). - assert((text.size() >= 1) && (text[0] == MESSAGE_FLAG)); + isc_throw_assert((text.size() >= 1) && (text[0] == MESSAGE_FLAG)); // A line comprising just the message introducer is not valid. if (text.size() == 1) { diff --git a/src/lib/util/buffer.h b/src/lib/util/buffer.h index 5640595053..128db99980 100644 --- a/src/lib/util/buffer.h +++ b/src/lib/util/buffer.h @@ -1,4 +1,4 @@ -// Copyright (C) 2009-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2009-2020 Internet Systems Consortium, Inc. ("ISC") // // 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 @@ -408,7 +408,10 @@ public: /// /// \param pos The position in the buffer to be returned. uint8_t operator[](size_t pos) const { - assert (pos < size_); + if (pos >= size_) { + isc_throw(InvalidBufferPosition, + "[]: pos (" << pos << ") >= size (" << size_ << ")"); + } return (buffer_[pos]); } //@} diff --git a/src/lib/util/encode/base16_from_binary.h b/src/lib/util/encode/base16_from_binary.h index f5674fdac4..3eb697dcc3 100644 --- a/src/lib/util/encode/base16_from_binary.h +++ b/src/lib/util/encode/base16_from_binary.h @@ -11,7 +11,7 @@ // See http://www.boost.org for updates, documentation, and revision history. -#include +#include #include // size_t #include // for BOOST_DEDUCED_TYPENAME @@ -40,7 +40,7 @@ struct from_4_bit { const char * lookup_table = "0123456789" "ABCDEF"; - assert(t < 16); + isc_throw_assert(t < 16); return (lookup_table[static_cast(t)]); } }; diff --git a/src/lib/util/encode/base32hex_from_binary.h b/src/lib/util/encode/base32hex_from_binary.h index 39216c2471..84f2b69b3f 100644 --- a/src/lib/util/encode/base32hex_from_binary.h +++ b/src/lib/util/encode/base32hex_from_binary.h @@ -11,7 +11,7 @@ // See http://www.boost.org for updates, documentation, and revision history. -#include +#include #include // size_t #include // for BOOST_DEDUCED_TYPENAME @@ -42,7 +42,7 @@ struct from_5_bit { const char * lookup_table = "0123456789" "ABCDEFGHIJKLMNOPQRSTUV"; - assert(t < 32); + isc_throw_assert(t < 32); return (lookup_table[static_cast(t)]); } }; diff --git a/src/lib/util/encode/base_n.cc b/src/lib/util/encode/base_n.cc index 82e5482492..eb0eb2358f 100644 --- a/src/lib/util/encode/base_n.cc +++ b/src/lib/util/encode/base_n.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2010-2019 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2010-2020 Internet Systems Consortium, Inc. ("ISC") // // 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 @@ -14,6 +14,7 @@ #include #include +#include #include #include @@ -26,7 +27,6 @@ #include #include -#include #include #include #include @@ -308,7 +308,7 @@ BaseNTransformer::encode( result.reserve(len); result.assign(Encoder(EncodeNormalizer(binary.begin(), binary.end())), Encoder(EncodeNormalizer(binary.end(), binary.end()))); - assert(len >= result.length()); + isc_throw_assert(len >= result.length()); result.append(len - result.length(), BASE_PADDING_CHAR); return (result); } @@ -402,7 +402,7 @@ BaseNTransformer::decode( // data, that is, that the first byte of padding is indeed 0. // (DecodeNormalizer and binary_from_baseXX ensure that the rest of the // padding is all zero). - assert(result.size() >= padbytes); + isc_throw_assert(result.size() >= padbytes); if (padbytes > 0 && *(result.end() - padbytes) != 0) { isc_throw(BadValue, "Non 0 bits included in " << algorithm << " padding: " << input); diff --git a/src/lib/util/io/sockaddr_util.h b/src/lib/util/io/sockaddr_util.h index 554602fdd4..1cb31f2028 100644 --- a/src/lib/util/io/sockaddr_util.h +++ b/src/lib/util/io/sockaddr_util.h @@ -1,4 +1,4 @@ -// Copyright (C) 2011-2015 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 // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -11,7 +11,7 @@ #include #include -#include +#include // These definitions in this file are for the convenience of internal // implementation and test code, and are not intended to be used publicly. @@ -27,7 +27,7 @@ getSALength(const struct sockaddr& sa) { if (sa.sa_family == AF_INET) { return (sizeof(struct sockaddr_in)); } else { - assert(sa.sa_family == AF_INET6); + isc_throw_assert(sa.sa_family == AF_INET6); return (sizeof(struct sockaddr_in6)); } } diff --git a/src/lib/util/io/socketsession.cc b/src/lib/util/io/socketsession.cc index ff51debc8d..573931a30e 100644 --- a/src/lib/util/io/socketsession.cc +++ b/src/lib/util/io/socketsession.cc @@ -1,4 +1,4 @@ -// 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 // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -22,7 +22,6 @@ #include #include #include -#include #include #include @@ -30,6 +29,7 @@ #include #include +#include #include @@ -105,7 +105,7 @@ SocketSessionForwarder::SocketSessionForwarder(const std::string& unix_file) : memset(&impl.sock_un_.sun_path, 0, sizeof(impl.sock_un_.sun_path)); strncpy(impl.sock_un_.sun_path, unix_file.c_str(), sizeof(impl.sock_un_.sun_path) - 1); - assert(impl.sock_un_.sun_path[sizeof(impl.sock_un_.sun_path) - 1] == '\0'); + isc_throw_assert(impl.sock_un_.sun_path[sizeof(impl.sock_un_.sun_path) - 1] == '\0'); impl.sock_un_len_ = offsetof(struct sockaddr_un, sun_path) + unix_file.length(); #ifdef HAVE_SA_LEN @@ -232,7 +232,7 @@ SocketSessionForwarder::push(int sock, int family, int type, int protocol, impl_->buf_.writeData(&remote_end, getSALength(remote_end)); // Data length. Must be fit uint32 due to the range check above. const uint32_t data_len32 = static_cast(data_len); - assert(data_len == data_len32); // shouldn't cause overflow. + isc_throw_assert(data_len == data_len32); // shouldn't cause overflow. impl_->buf_.writeUint32(data_len32); // Write the resulting header length at the beginning of the buffer impl_->buf_.writeUint16At(impl_->buf_.getLength() - sizeof(uint16_t), 0); diff --git a/src/lib/util/random/random_number_generator.h b/src/lib/util/random/random_number_generator.h index da3f0be407..5f50ee7ccf 100644 --- a/src/lib/util/random/random_number_generator.h +++ b/src/lib/util/random/random_number_generator.h @@ -1,4 +1,4 @@ -// Copyright (C) 2010-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2010-2020 Internet Systems Consortium, Inc. ("ISC") // // 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 @@ -92,12 +92,12 @@ class WeightedRandomIntegerGenerator { public: /// \brief Constructor /// - /// \param probabilities The probabilities for all the integers, the probability must be + /// \param probabilities The probabilities for all the integers, the probability must be /// between 0 and 1.0, the sum of probabilities must be equal to 1. /// For example, if the probabilities contains the following values: /// 0.5 0.3 0.2, the 1st integer will be generated more frequently than the /// other integers and the probability is proportional to its value. - /// \param min The minimum integer that generated, other integers will be + /// \param min The minimum integer that generated, other integers will be /// min, min + 1, ..., min + probabilities.size() - 1 WeightedRandomIntegerGenerator(const std::vector& probabilities, size_t min = 0): @@ -105,7 +105,7 @@ public: { // The probabilities must be valid. Checking is quite an expensive // operation, so is only done in a debug build. - assert(areProbabilitiesValid(probabilities)); + areProbabilitiesValid(probabilities); // Calculate the partial sum of probabilities std::partial_sum(probabilities.begin(), probabilities.end(), @@ -129,7 +129,7 @@ public: void reset(const std::vector& probabilities, size_t min = 0) { // The probabilities must be valid. - assert(areProbabilitiesValid(probabilities)); + areProbabilitiesValid(probabilities); // Reset the cumulative sum cumulative_.clear(); @@ -145,7 +145,7 @@ public: /// \brief Generate weighted random integer size_t operator()() { - return std::lower_bound(cumulative_.begin(), cumulative_.end(), uniform_real_gen_()) + return std::lower_bound(cumulative_.begin(), cumulative_.end(), uniform_real_gen_()) - cumulative_.begin() + min_; } @@ -161,31 +161,31 @@ private: /// error, an exception is thrown. This makes unit testing somewhat easier. /// /// \param probabilities Vector of probabilities. - bool areProbabilitiesValid(const std::vector& probabilities) const + /// \throw InvalidProbValue or SumNotOne when not valid. + void areProbabilitiesValid(const std::vector& probabilities) const { - typedef std::vector::const_iterator Iterator; double sum = probabilities.empty() ? 1.0 : 0.0; - for(Iterator it = probabilities.begin(); it != probabilities.end(); ++it){ + for (const double it : probabilities) { //The probability must be in [0, 1.0] - if(*it < 0.0 || *it > 1.0) { + if (it < 0.0 || it > 1.0) { isc_throw(InvalidProbValue, "probability must be in the range 0..1"); } - sum += *it; + sum += it; } double epsilon = 0.0001; // The sum must be equal to 1 - if (std::fabs(sum - 1.0) >= epsilon) { - isc_throw(SumNotOne, "Sum of probabilities is not equal to 1"); - } + if (std::fabs(sum - 1.0) >= epsilon) { + isc_throw(SumNotOne, "Sum of probabilities is not equal to 1"); + } - return true; + return; } std::vector cumulative_; ///< Partial sum of the probabilities - boost::mt19937 rng_; ///< Mersenne Twister: A 623-dimensionally equidistributed uniform pseudo-random number generator + boost::mt19937 rng_; ///< Mersenne Twister: A 623-dimensionally equidistributed uniform pseudo-random number generator boost::uniform_real<> dist_; ///< Uniformly distributed real numbers // Shortcut typedef diff --git a/src/lib/util/tests/buffer_unittest.cc b/src/lib/util/tests/buffer_unittest.cc index 9e4294f951..1f631673da 100644 --- a/src/lib/util/tests/buffer_unittest.cc +++ b/src/lib/util/tests/buffer_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2009-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2009-2020 Internet Systems Consortium, Inc. ("ISC") // // 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 @@ -181,21 +181,7 @@ TEST_F(BufferTest, outputBufferReadAt) { for (int i = 0; i < sizeof(testdata); i ++) { EXPECT_EQ(testdata[i], obuffer[i]); } -#ifdef EXPECT_DEATH - // We use assert now, so we check it dies - if (!isc::util::unittests::runningOnValgrind()) { - EXPECT_DEATH({ - isc::util::unittests::dontCreateCoreDumps(); - - try { - obuffer[sizeof(testdata)]; - } catch (...) { - // Prevent exceptions killing the application, we need - // to make sure it dies the real hard way - } - }, ""); - } -#endif + EXPECT_THROW(obuffer[sizeof(testdata)], isc::util::InvalidBufferPosition); } TEST_F(BufferTest, outputBufferClear) {