Verified Commit 9abbf8e9 authored by Andrei Pavel's avatar Andrei Pavel 🐧

[#1298] fix non-printable numeric_limits

* fix non-printable characters which were the result of numeric_limits<T>::*
being passed to a stringstream when T is an 8 byte integer equivalent to a char
* also removed a few spurious spaces
parent 2f519222
......@@ -427,8 +427,9 @@ TSIGKeyInfoParser::parse(ConstElementPtr key_config) {
&& (digestbits < 192)) ||
(boost::iequals(algorithm, TSIGKeyInfo::HMAC_SHA512_STR)
&& (digestbits < 256)))) {
isc_throw(D2CfgError, "tsig-key: digest-bits too small : "
<< " (" << getPosition("digest-bits", key_config) << ")");
isc_throw(D2CfgError, "tsig-key: digest-bits too small : ("
<< getPosition("digest-bits", key_config)
<< ")");
}
// Everything should be valid, so create the key instance.
......
......@@ -248,8 +248,8 @@ void D2SimpleParser::parse(const D2CfgContextPtr& ctx,
if (ncr_protocol != dhcp_ddns::NCR_UDP) {
isc_throw(D2CfgError, "ncr-protocol : "
<< dhcp_ddns::ncrProtocolToString(ncr_protocol)
<< " is not yet supported "
<< " (" << config->get("ncr-protocol")->getPosition() << ")");
<< " is not yet supported ("
<< config->get("ncr-protocol")->getPosition() << ")");
}
ncr_format = getFormat(config, "ncr-format");
......
......@@ -939,8 +939,7 @@ TEST_F(D2CfgMgrTest, configPermutations) {
// Grab the test's configuration data.
isc::data::ConstElementPtr data = test->get("data");
ASSERT_TRUE(data) << "No data for test: "
<< " : " << test->getPosition();
ASSERT_TRUE(data) << "No data for test: " << test->getPosition();
// Convert the test data back to JSON text, then submit it for parsing.
stringstream os;
......
......@@ -254,8 +254,9 @@ T HAConfigParser::getAndValidateInteger(const ConstElementPtr& config,
isc_throw(ConfigError, "'" << parameter_name << "' must not be negative");
} else if (value > std::numeric_limits<T>::max()) {
isc_throw(ConfigError, "'" << parameter_name << "' must not be greater than "
<< std::numeric_limits<T>::max());
isc_throw(ConfigError,
"'" << parameter_name << "' must not be greater than "
<< std::to_string(std::numeric_limits<T>::max()));
}
return (static_cast<T>(value));
......
......@@ -210,8 +210,8 @@ JSONFeed::getNextFromBuffer() {
void
JSONFeed::invalidEventError(const std::string& handler_name,
const unsigned int event) {
isc_throw(JSONFeedError, handler_name << ": "
<< " invalid event " << getEventLabel(static_cast<int>(event)));
isc_throw(JSONFeedError, handler_name << ": invalid event "
<< getEventLabel(static_cast<int>(event)));
}
void
......
......@@ -275,8 +275,9 @@ CqlBindUdt(const boost::any& value,
} catch (const boost::bad_any_cast& exception) {
isc_throw(DbOperationError,
"CqlCommon::udtSetData(): "
<< exception.what() << " when binding parameter "
<< " of type " << element.type().name()
<< exception.what()
<< " when binding parameter of type "
<< element.type().name()
<< "in UDT with function CQL_FUNCTIONS["
<< exchangeType(element) << "].cqlUdtSetFunction_");
}
......
......@@ -193,8 +193,9 @@ DbAccessParser::parse(std::string& access_string,
// Check that the max-reconnect-tries is reasonable.
if (max_reconnect_tries < 0) {
ConstElementPtr value = database_config->get("max-reconnect-tries");
isc_throw(DbConfigError, "max-reconnect-tries cannot be less than zero: "
<< " (" << value->getPosition() << ")");
isc_throw(DbConfigError,
"max-reconnect-tries cannot be less than zero: ("
<< value->getPosition() << ")");
}
// Check that the reconnect-wait-time is reasonable.
......@@ -203,7 +204,7 @@ DbAccessParser::parse(std::string& access_string,
ConstElementPtr value = database_config->get("reconnect-wait-time");
isc_throw(DbConfigError, "reconnect-wait-time " << reconnect_wait_time
<< " must be in range 0...MAX_UINT32 (4294967295) "
<< " (" << value->getPosition() << ")");
<< "(" << value->getPosition() << ")");
}
// Check that request_timeout value makes sense.
......@@ -212,7 +213,7 @@ DbAccessParser::parse(std::string& access_string,
ConstElementPtr value = database_config->get("request-timeout");
isc_throw(DbConfigError, "request-timeout " << request_timeout
<< " must be in range 0...MAX_UINT32 (4294967295) "
<< " (" << value->getPosition() << ")");
<< "(" << value->getPosition() << ")");
}
if ((reconnect_wait_time < 0) ||
......@@ -220,7 +221,7 @@ DbAccessParser::parse(std::string& access_string,
ConstElementPtr value = database_config->get("reconnect-wait-time");
isc_throw(DbConfigError, "reconnect-wait-time " << reconnect_wait_time
<< " must be in range 0...MAX_UINT32 (4294967295) "
<< " (" << value->getPosition() << ")");
<< "(" << value->getPosition() << ")");
}
// Check that tcp_keepalive value makes sense.
......@@ -229,7 +230,7 @@ DbAccessParser::parse(std::string& access_string,
ConstElementPtr value = database_config->get("tcp-keepalive");
isc_throw(DbConfigError, "tcp-keepalive " << tcp_keepalive
<< " must be in range 0...MAX_UINT32 (4294967295) "
<< " (" << value->getPosition() << ")");
<< "(" << value->getPosition() << ")");
}
// 4. If all is OK, update the stored keyword/value pairs. We do this by
......
......@@ -236,7 +236,8 @@ OptionDataTypeUtil::writeTuple(const std::string& value,
if (value.size() > std::numeric_limits<uint8_t>::max()) {
isc_throw(BadDataTypeCast, "invalid tuple value (size "
<< value.size() << " larger than "
<< std::numeric_limits<uint8_t>::max() << ")");
<< std::to_string(std::numeric_limits<uint8_t>::max())
<< ")");
}
buf.push_back(static_cast<uint8_t>(value.size()));
......@@ -267,7 +268,8 @@ OptionDataTypeUtil::writeTuple(const OpaqueDataTuple& tuple,
if (tuple.getLength() > std::numeric_limits<uint8_t>::max()) {
isc_throw(BadDataTypeCast, "invalid tuple value (size "
<< tuple.getLength() << " larger than "
<< std::numeric_limits<uint8_t>::max() << ")");
<< std::to_string(std::numeric_limits<uint8_t>::max())
<< ")");
}
buf.push_back(static_cast<uint8_t>(tuple.getLength()));
......@@ -580,7 +582,7 @@ OptionDataTypeUtil::readString(const std::vector<uint8_t>& buf) {
auto end = util::str::seekTrimmed(begin, buf.end(), 0x0);
if (std::distance(begin, end) == 0) {
isc_throw(isc::OutOfRange, "string value carried by the option "
<< " contained only NULLs");
"contained only NULLs");
}
value.insert(value.end(), begin, end);
......
......@@ -603,9 +603,9 @@ OptionDefinition::lexicalCastWithRangeCheck(const std::string& value_str)
result < numeric_limits<T>::min()) {
isc_throw(BadDataTypeCast, "unable to convert '"
<< value_str << "' to numeric type. This value is "
" expected to be in the range of "
<< numeric_limits<T>::min()
<< ".." << numeric_limits<T>::max());
"expected to be in the range of "
<< to_string(numeric_limits<T>::min()) << ".."
<< to_string(numeric_limits<T>::max()));
}
}
return (static_cast<T>(result));
......
......@@ -328,7 +328,7 @@ RelayInfoParser::parse(const isc::dhcp::Network::RelayInfoPtr& relay_info,
if (addresses->getType() != Element::list) {
isc_throw(DhcpConfigError, "ip-addresses must be a list "
<< " (" << getPosition("ip-addresses", relay_elem) << ")");
"(" << getPosition("ip-addresses", relay_elem) << ")");
}
BOOST_FOREACH(ConstElementPtr address_element, addresses->listValue()) {
......
......@@ -221,9 +221,9 @@ HttpMessageParserBase::getNextFromBuffer(std::string& bytes, const size_t limit)
void
HttpMessageParserBase::invalidEventError(const std::string& handler_name,
const unsigned int event) {
isc_throw(HttpParseError, handler_name << ": "
<< " invalid event " << getEventLabel(static_cast<int>(event)));
const unsigned int event) {
isc_throw(HttpParseError, handler_name << ": invalid event "
<< getEventLabel(static_cast<int>(event)));
}
void
......
......@@ -110,9 +110,9 @@ WatchSocket::clearReady() {
// or testing the fd with select_fd will fail.
const char* errstr = strerror(errno);
closeSocket();
isc_throw(WatchSocketError, "WatchSocket clearReady failed:"
<< " bytes read: " << nbytes << " : "
<< " value read: " << buf << " error :" <<errstr);
isc_throw(WatchSocketError, "WatchSocket clearReady failed: "
"bytes read: " << nbytes << " : "
"value read: " << buf << " error :" << errstr);
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment