face: Gracefully handle tlv::Error when received TLV block is malformed
Change-Id: I954b13d0e26fec7bc7fe23edcbc015dfac654ef8 Refs: #1494
This commit is contained in:
+21
-16
@@ -90,24 +90,29 @@ Face::isUp() const
|
||||
bool
|
||||
Face::decodeAndDispatchInput(const Block& element)
|
||||
{
|
||||
/// \todo Ensure lazy field decoding process
|
||||
try {
|
||||
/// \todo Ensure lazy field decoding process
|
||||
|
||||
if (element.type() == tlv::Interest)
|
||||
{
|
||||
shared_ptr<Interest> i = make_shared<Interest>();
|
||||
i->wireDecode(element);
|
||||
this->onReceiveInterest(*i);
|
||||
}
|
||||
else if (element.type() == tlv::Data)
|
||||
{
|
||||
shared_ptr<Data> d = make_shared<Data>();
|
||||
d->wireDecode(element);
|
||||
this->onReceiveData(*d);
|
||||
}
|
||||
else
|
||||
if (element.type() == tlv::Interest)
|
||||
{
|
||||
shared_ptr<Interest> i = make_shared<Interest>();
|
||||
i->wireDecode(element);
|
||||
this->onReceiveInterest(*i);
|
||||
}
|
||||
else if (element.type() == tlv::Data)
|
||||
{
|
||||
shared_ptr<Data> d = make_shared<Data>();
|
||||
d->wireDecode(element);
|
||||
this->onReceiveData(*d);
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (tlv::Error&) {
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace nfd
|
||||
|
||||
Reference in New Issue
Block a user