From ad4ea699a5f6fa2d7c0ad784ee64e8f044b057c6 Mon Sep 17 00:00:00 2001 From: Deon George Date: Fri, 7 Jul 2023 23:13:43 +1000 Subject: [PATCH] Fix BINKP transfers when tcp buffer has more chars than we need at that point in time --- app/Classes/Protocol/Binkp.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/Classes/Protocol/Binkp.php b/app/Classes/Protocol/Binkp.php index 35b278a..da3eb4b 100644 --- a/app/Classes/Protocol/Binkp.php +++ b/app/Classes/Protocol/Binkp.php @@ -359,9 +359,9 @@ final class Binkp extends BaseProtocol if ($blksz !== 0) { try { - Log::debug(sprintf('%s:- Reading [%d] chars, buffer currently has [%d] chars',self::LOGKEY,$blksz,strlen($this->rx_buf))); - $rx_buf = $this->client->read(0,$blksz); - Log::debug(sprintf('%s:- Read buffer now has [%d] chars',self::LOGKEY,strlen($rx_buf))); + Log::debug(sprintf('%s:- We need [%d] more chars, buffer currently has [%d] chars',self::LOGKEY,$blksz,strlen($this->rx_buf))); + $rx_buf = $this->client->read(0,$blksz-strlen($this->rx_buf)); + Log::debug(sprintf('%s:- Got [%d] more chars for the read buffer',self::LOGKEY,strlen($rx_buf))); } catch (SocketException $e) { if ($e->getCode() === 11) { @@ -389,8 +389,7 @@ final class Binkp extends BaseProtocol $this->rx_buf .= ($this->capGet(self::F_CRYPT,self::O_YES)) ? $this->crypt_in->decrypt($rx_buf) : $rx_buf; } - if ($this->DEBUG) - Log::debug(sprintf('%s: - binkp_recv rx_buf [%d] blksz [%d].',self::LOGKEY,strlen($this->rx_buf),$blksz)); + Log::debug(sprintf('%s:- Read buffer has [%d] chars to process.',self::LOGKEY,strlen($this->rx_buf))); /* Received complete block */ if (strlen($this->rx_buf) === $blksz) {