Throw an exception when we cannot determine the end of the message/packet

This commit is contained in:
Deon George 2023-11-15 22:12:09 +11:00
parent 3b99c409e0
commit 7087fe9bbb
1 changed files with 9 additions and 5 deletions

View File

@ -145,7 +145,7 @@ class Packet extends FTNBase implements \Iterator, \Countable
/* STATIC */
/**
* Site of the packet header
* Size of the packet header
*
* @return int
*/
@ -303,11 +303,15 @@ class Packet extends FTNBase implements \Iterator, \Countable
}
// See if we have found the end of the packet, if not read more.
if ($end === FALSE && ($read_ptr < $size)) {
$message .= substr($readbuf,$buf_ptr);
$buf_ptr = 0;
if ($end === FALSE) {
if ($read_ptr < $size) {
$message .= substr($readbuf,$buf_ptr);
$buf_ptr = 0;
continue;
continue;
} else
throw new InvalidPacketException(sprintf('Cannot determine END of message/packet: %s|%s',get_class($o),hex_dump($message)));
} else {
$message .= substr($readbuf,$buf_ptr,$end-$buf_ptr);