Fixes based on review by @steve-lad

This commit is contained in:
dkgroot 2021-06-27 07:54:00 +00:00
parent 838ff633aa
commit 4da4f391d6
2 changed files with 8 additions and 8 deletions

View file

@ -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

View file

@ -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"];
}
}