From c86d8d895220901f54083d9155df85f2cd7ef521 Mon Sep 17 00:00:00 2001 From: Deon George Date: Thu, 5 Oct 2023 20:49:58 +1100 Subject: [PATCH] Logging to catch some hex2bin exceptions with 2/109 --- app/Classes/Protocol/Binkp.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/Classes/Protocol/Binkp.php b/app/Classes/Protocol/Binkp.php index 14183d3..ff2cb03 100644 --- a/app/Classes/Protocol/Binkp.php +++ b/app/Classes/Protocol/Binkp.php @@ -1153,12 +1153,15 @@ final class Binkp extends BaseProtocol $this->capSet(self::F_COMP,self::O_THEY|self::O_EXT); } elseif (! strncmp($p,'CRAM-MD5-',9) && $this->originate && $this->capGet(self::F_MD,self::O_WANT)) { - if (($x=strlen(substr($p,9))) > 64 ) { - Log::error(sprintf('%s:! The challenge string is TOO LONG [%d] (%s)',self::LOGKEY,$x,$p)); + if (strlen($hex=substr($p,9)) > 64 ) { + Log::error(sprintf('%s:! The challenge string is TOO LONG [%d] (%s)',self::LOGKEY,strlen($hex),$p)); + + } elseif (strlen($hex)%2) { + Log::error(sprintf('%s:! The challenge string is an odd size [%d] (%s)',self::LOGKEY,strlen($hex),$hex)); } else { - Log::info(sprintf('%s:- Remote wants MD5 auth',self::LOGKEY)); - $this->md_challenge = hex2bin(substr($p,9)); + Log::info(sprintf('%s:- Remote wants MD5 auth with [%s]',self::LOGKEY,$hex)); + $this->md_challenge = hex2bin($hex); if ($this->md_challenge) $this->capSet(self::F_MD,self::O_THEY); @@ -1385,6 +1388,8 @@ final class Binkp extends BaseProtocol // We dont have anything to send } else { Log::info(sprintf('%s:- Nothing left to send in this batch',self::LOGKEY)); + // @todo We should look for more mail/files before thinking about sending an EOB + // IE: When we are set to only send X messages, but we have > X to send, get the next batch. $this->sessionSet(self::SE_NOFILES); } }