Check integer range during decoding
This commit also moves ControlResponse test suite to the correct
place under mgmt/ instead of mgmt/nfd/.
refs #3200
Change-Id: I1a0578b3e68b8c36c84a6af03d0c47bebe598fe1
diff --git a/src/meta-info.cpp b/src/meta-info.cpp
index 41ad0f7..dcafb18 100644
--- a/src/meta-info.cpp
+++ b/src/meta-info.cpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2013-2017 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -205,7 +205,7 @@
// ContentType
if (val != m_wire.elements_end() && val->type() == tlv::ContentType) {
- m_type = readNonNegativeInteger(*val);
+ m_type = readNonNegativeIntegerAs<uint32_t>(*val);
++val;
}
else {
diff --git a/src/mgmt/control-response.cpp b/src/mgmt/control-response.cpp
index 9d82d40..3045783 100644
--- a/src/mgmt/control-response.cpp
+++ b/src/mgmt/control-response.cpp
@@ -79,7 +79,7 @@
if (val == m_wire.elements_end() || val->type() != tlv::nfd::StatusCode) {
BOOST_THROW_EXCEPTION(Error("missing StatusCode sub-element"));
}
- m_code = readNonNegativeInteger(*val);
+ m_code = readNonNegativeIntegerAs<uint32_t>(*val);
++val;
if (val == m_wire.elements_end() || val->type() != tlv::nfd::StatusText) {
diff --git a/src/selectors.cpp b/src/selectors.cpp
index 8890b58..a207775 100644
--- a/src/selectors.cpp
+++ b/src/selectors.cpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2013-2017 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -145,13 +145,13 @@
// MinSuffixComponents
Block::element_const_iterator val = m_wire.find(tlv::MinSuffixComponents);
if (val != m_wire.elements_end()) {
- m_minSuffixComponents = readNonNegativeInteger(*val);
+ m_minSuffixComponents = readNonNegativeIntegerAs<int>(*val);
}
// MaxSuffixComponents
val = m_wire.find(tlv::MaxSuffixComponents);
if (val != m_wire.elements_end()) {
- m_maxSuffixComponents = readNonNegativeInteger(*val);
+ m_maxSuffixComponents = readNonNegativeIntegerAs<int>(*val);
}
// PublisherPublicKeyLocator
@@ -169,7 +169,7 @@
// ChildSelector
val = m_wire.find(tlv::ChildSelector);
if (val != m_wire.elements_end()) {
- m_childSelector = readNonNegativeInteger(*val);
+ m_childSelector = readNonNegativeIntegerAs<bool>(*val);
}
else {
m_childSelector = DEFAULT_CHILD_SELECTOR;