face: drop WebSocket message if the size is larger than maximum NDN packet size
Change-Id: I8e2bd81bbd0d4ba3598ab7c16a3125189b38ca4f
refs: #2081
diff --git a/daemon/face/websocket-face.cpp b/daemon/face/websocket-face.cpp
index 5b295b3..5c999a1 100644
--- a/daemon/face/websocket-face.cpp
+++ b/daemon/face/websocket-face.cpp
@@ -99,7 +99,13 @@
WebSocketFace::handleReceive(const std::string& msg)
{
// Copy message into Face internal buffer
- BOOST_ASSERT(msg.size() <= MAX_NDN_PACKET_SIZE);
+ if (msg.size() > MAX_NDN_PACKET_SIZE)
+ {
+ NFD_LOG_WARN("[id:" << this->getId()
+ << "] Received WebSocket message size ["
+ << msg.size() << "] is too big");
+ return;
+ }
this->getMutableCounters().getNInBytes() += msg.size();
@@ -109,9 +115,9 @@
isOk = Block::fromBuffer(reinterpret_cast<const uint8_t*>(msg.c_str()), msg.size(), element);
if (!isOk)
{
- NFD_LOG_TRACE("[id:" << this->getId()
- << "] Received invalid NDN packet of length ["
- << msg.size() << "]");
+ NFD_LOG_WARN("[id:" << this->getId()
+ << "] Received invalid NDN packet of length ["
+ << msg.size() << "]");
return;
}