From 050b1b615bf8931265a8a1ad73fc9e3a56881502 Mon Sep 17 00:00:00 2001 From: ShevAbam Date: Tue, 3 Apr 2018 10:01:07 +0200 Subject: [PATCH] Scan Port : check the return of the fwrite #59 --- libs/Utils/Misc.php | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/libs/Utils/Misc.php b/libs/Utils/Misc.php index 7aab276..132ccd3 100644 --- a/libs/Utils/Misc.php +++ b/libs/Utils/Misc.php @@ -189,20 +189,27 @@ class Misc $write = fwrite($handle, 'x00'); - $startTime = time(); - - $header = fread($handle, 1); - - $endTime = time(); - - $timeDiff = $endTime - $startTime; - - fclose($handle); - - if ($timeDiff >= $timeout) - return true; - else + if ($write === false) + { return false; + } + else + { + $startTime = time(); + + $header = fread($handle, 1); + + $endTime = time(); + + $timeDiff = $endTime - $startTime; + + fclose($handle); + + if ($timeDiff >= $timeout) + return true; + else + return false; + } } return false;