From d4263e854d2ad74522dcdce7f920c33cc5e1c16e Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Tue, 18 Apr 2023 15:16:18 -0500 Subject: [PATCH] update exception message `fputs()` can return `int|false`. if it fails and `$sent` is `false`, then our exception message looks a little confusing: > Only of XXX bytes were sent This change updates the message to be more descriptive if the `fputs()` fails. --- phpseclib/Net/SSH2.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index 88a92f24..de020e95 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -4266,7 +4266,8 @@ class SSH2 if (strlen($packet) != $sent) { $this->bitmap = 0; - throw new \RuntimeException("Only $sent of " . strlen($packet) . " bytes were sent"); + $message = $sent === false ? ('Unable to write ' . strlen($packet) . ' bytes') : ("Only $sent of " . strlen($packet) . " bytes were sent"); + throw new \RuntimeException($message); } }