From 7087fe9bbbbb929531073e774dea6f0dc1ea5441 Mon Sep 17 00:00:00 2001 From: Deon George Date: Wed, 15 Nov 2023 22:12:09 +1100 Subject: [PATCH] Throw an exception when we cannot determine the end of the message/packet --- app/Classes/FTN/Packet.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/Classes/FTN/Packet.php b/app/Classes/FTN/Packet.php index 8d75c91..31f6df9 100644 --- a/app/Classes/FTN/Packet.php +++ b/app/Classes/FTN/Packet.php @@ -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);