From 8e5739b21f6c8d30b11906bedc37ef733af5a4fe Mon Sep 17 00:00:00 2001 From: Namoshek Date: Wed, 1 Jul 2020 21:07:29 +0200 Subject: [PATCH] Fix: use addition to increase message size When using a username and password to connect to a broker, the message size has been manipulated using string concatenation instead of mathematical addition. This caused an issue with `chr()` expecting an integer and not a string. It also would have lead to wrong information being sent. --- src/MQTTClient.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MQTTClient.php b/src/MQTTClient.php index ef490f2..53ca685 100644 --- a/src/MQTTClient.php +++ b/src/MQTTClient.php @@ -223,12 +223,12 @@ protected function performConnectionHandshake(string $username = null, string $p if ($username !== null) { $usernamePart = $this->buildLengthPrefixedString($username); $buffer .= $usernamePart; - $i .= strlen($usernamePart); + $i += strlen($usernamePart); } if ($password !== null) { $passwordPart = $this->buildLengthPrefixedString($password); $buffer .= $passwordPart; - $i .= strlen($passwordPart); + $i += strlen($passwordPart); } // message type and message length