Skip to content

Commit

Permalink
Fix unknown read in TelnetLayer (#1534)
Browse files Browse the repository at this point in the history
* Fix unknown read in TelnetLayer

* need at least 2 bytes for command

* fix formatting

---------

Co-authored-by: Liu, An-Chi <[email protected]>
  • Loading branch information
egecetin and tigercosmos authored Aug 14, 2024
1 parent 0cc772e commit 6627ab7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Packet++/src/TelnetLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ namespace pcpp
pos += length;
offset += length;

if (isCommandField(pos))
if ((static_cast<size_t>(pos - m_Data) <= (m_DataLen - 2)) &&
isCommandField(pos)) // Need at least 2 bytes for command
return pos;
}

Expand Down
Binary file not shown.

0 comments on commit 6627ab7

Please sign in to comment.