From 4da4f391d6435f63333beb66d16dac8a459e7d6e Mon Sep 17 00:00:00 2001 From: dkgroot Date: Sun, 27 Jun 2021 07:54:00 +0000 Subject: [PATCH] Fixes based on review by @steve-lad --- install.php | 7 +------ sccpManTraits/helperFunctions.php | 9 +++++++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/install.php b/install.php index b0fc79d..e73077c 100644 --- a/install.php +++ b/install.php @@ -898,12 +898,7 @@ function checkTftpServer() { foreach ($possibleFtpDirs as $dirToTest) { if (is_dir($dirToTest) && is_writable($dirToTest) && empty($tftpRootPath)) { $tempFile = "${dirToTest}/{$remoteFileName}"; - $FH = fopen($tempFile, "w"); - if ($FH == null) { - continue; - } - fwrite($FH, $remoteFileContent); - fclose($FH); + file_put_contents($tempFile, $remoteFileContent); // try to pull the written file through tftp. // this way we can determine if tftp server is active, and what it's diff --git a/sccpManTraits/helperFunctions.php b/sccpManTraits/helperFunctions.php index dfa88ec..6019262 100644 --- a/sccpManTraits/helperFunctions.php +++ b/sccpManTraits/helperFunctions.php @@ -182,10 +182,15 @@ trait helperfunctions { $numbytes = socket_recvfrom($socket, $buffer, 84, MSG_WAITALL, $host, $port); // unpack the returned buffer and discard the first two bytes - $pkt = unpack("n2/a*data", $buffer); + $pkt = unpack("nopcode/nblockno/a*data", $buffer); + + // send ack + $packet = chr(4) . chr(pkt["blockno"]); + socket_sendto($socket, $packet, strlen($packet), MSG_EOR, $host, $port); socket_close($socket); - if ($numbytes) { + + if ($pkt["opcode"] == 3 && $numbytes) { return $pkt["data"]; } }