From 8f69fcc31c29e7820dfb653ac411a09e90196c9c Mon Sep 17 00:00:00 2001 From: DILLY Bertrand Date: Thu, 27 Feb 2025 08:55:25 +0100 Subject: [PATCH] Corr sending of file through socket. Original code keep responding 'ok' (tested with EICAR file) --- src/ClamAV/ClamAV.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ClamAV/ClamAV.php b/src/ClamAV/ClamAV.php index 83630ac..3f1efc3 100644 --- a/src/ClamAV/ClamAV.php +++ b/src/ClamAV/ClamAV.php @@ -105,8 +105,9 @@ public function fileScanInStream(string $file): bool while (!\feof($handle)) { $data = \fread($handle, $chunkSize); - $packet = \pack(\sprintf("Na%d", $chunkSize), $chunkSize, $data); - \socket_send($socket, $packet, $chunkSize + 4, 0); + $length = pack("N", strlen($data)); + socket_write($socket, $length, 4); + socket_write($socket, $data, strlen($data)); } \socket_send($socket, \pack("Nx", 0), 5, 0);