Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Packet++/src/BgpLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,11 @@ namespace pcpp

if (newNlriDataLen > curNlriDataLen)
{
if (newNlriDataLen < curNlriDataLen)
{
PCPP_LOG_ERROR("newNlriDataLen cannot be less than curNlriDataLen");
return false;
}
bool res = extendLayer(sizeof(bgp_common_header) + 2 * sizeof(uint16_t) + curWithdrawnRoutesDataLen +
curPathAttributesDataLen,
newNlriDataLen - curNlriDataLen);
Expand Down
5 changes: 5 additions & 0 deletions Packet++/src/Packet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,11 @@ namespace pcpp
bool Packet::extendLayer(Layer* layer, int offsetInLayer, size_t numOfBytesToExtend)
{
if (layer == nullptr)
if (numOfBytesToExtend < 0)
{
PCPP_LOG_ERROR("numOfBytesToExtend cannot be negative");
return false;
}
{
PCPP_LOG_ERROR("Layer is nullptr");
return false;
Expand Down
5 changes: 5 additions & 0 deletions Packet++/src/RawPacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ namespace pcpp
void RawPacket::insertData(int atIndex, const uint8_t* dataToInsert, size_t dataToInsertLen)
{
// memmove copies data as if there was an intermediate buffer in between - so it allows for copying processes on
if (dataToInsertLen < 0)
{
PCPP_LOG_ERROR("dataToInsertLen cannot be negative");
return;
}
// overlapping src/dest ptrs if insertData is called with atIndex == m_RawDataLen, then no data is being moved.
// The data of the raw packet is still extended by dataToInsertLen
memmove((uint8_t*)m_RawData + atIndex + dataToInsertLen, (uint8_t*)m_RawData + atIndex, m_RawDataLen - atIndex);
Expand Down
Loading