Skip to content

Commit 936c316

Browse files
committed
Add check to ensure offsetInLayer is not negative in Layer::extend/shorten
1 parent 4c839c7 commit 936c316

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Packet++/src/Layer.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ namespace pcpp
6161
return false;
6262
}
6363

64+
if (offsetInLayer < 0)
65+
{
66+
PCPP_LOG_ERROR("Requested offset is negative");
67+
return false;
68+
}
69+
6470
if (static_cast<size_t>(offsetInLayer) > m_DataLen)
6571
{
6672
PCPP_LOG_ERROR("Requested offset is larger than data length");
@@ -102,6 +108,12 @@ namespace pcpp
102108
return false;
103109
}
104110

111+
if (offsetInLayer < 0)
112+
{
113+
PCPP_LOG_ERROR("Requested offset is negative");
114+
return false;
115+
}
116+
105117
if (static_cast<size_t>(offsetInLayer) >= m_DataLen)
106118
{
107119
PCPP_LOG_ERROR("Requested offset is larger than data length");

0 commit comments

Comments
 (0)