Fixes based on review by @steve-lad
This commit is contained in:
parent
838ff633aa
commit
4da4f391d6
|
@ -898,12 +898,7 @@ function checkTftpServer() {
|
||||||
foreach ($possibleFtpDirs as $dirToTest) {
|
foreach ($possibleFtpDirs as $dirToTest) {
|
||||||
if (is_dir($dirToTest) && is_writable($dirToTest) && empty($tftpRootPath)) {
|
if (is_dir($dirToTest) && is_writable($dirToTest) && empty($tftpRootPath)) {
|
||||||
$tempFile = "${dirToTest}/{$remoteFileName}";
|
$tempFile = "${dirToTest}/{$remoteFileName}";
|
||||||
$FH = fopen($tempFile, "w");
|
file_put_contents($tempFile, $remoteFileContent);
|
||||||
if ($FH == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
fwrite($FH, $remoteFileContent);
|
|
||||||
fclose($FH);
|
|
||||||
|
|
||||||
// try to pull the written file through tftp.
|
// try to pull the written file through tftp.
|
||||||
// this way we can determine if tftp server is active, and what it's
|
// this way we can determine if tftp server is active, and what it's
|
||||||
|
|
|
@ -182,10 +182,15 @@ trait helperfunctions {
|
||||||
$numbytes = socket_recvfrom($socket, $buffer, 84, MSG_WAITALL, $host, $port);
|
$numbytes = socket_recvfrom($socket, $buffer, 84, MSG_WAITALL, $host, $port);
|
||||||
|
|
||||||
// unpack the returned buffer and discard the first two bytes
|
// 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);
|
socket_close($socket);
|
||||||
if ($numbytes) {
|
|
||||||
|
if ($pkt["opcode"] == 3 && $numbytes) {
|
||||||
return $pkt["data"];
|
return $pkt["data"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue