In Subs-Package.php, smf 1.1.2, the while condition in check_response() fails to get the response in some ftp servers:
function check_response($desired)
{
// Wait for a response that isn't continued with -, but don't wait too long.
$time = time();
do
$this->last_message = fgets($this->connection, 1024);
while (substr($this->last_message, 3, 1) != ' ' && time() - $time < 5);
// Was the desired response returned?
return is_array($desired) ? in_array(substr($this->last_message, 0, 3), $desired) : substr($this->last_message, 0, 3) == $desired;
}
It only checks for the third char being different than space.
But many ftp servers send disclaimers such as:
Response: 220-
Response: ================================================
Response: ******* Disclaimer *******
Response: ================================================
Response:
Response: Xx xxxxxx xxx xxxxxxxx xxxxxx xxxxx
In the above ftp server, the while condition would stop the loop in either the 5th or the 6th line.
So the correct condition should check for strlen() > 4 and first letter != ' '.
The fix:
function check_response($desired)
{
// Wait for a response that isn't continued with -, but don't wait too long.
$time = time();
do
$this->last_message = fgets($this->connection, 1024);
while ( (strlen($this->last_message) < 4 || substr($this->last_message, 0, 1) == ' ' || substr($this->last_message, 3, 1) != ' ') && time() - $time < 5);
// Was the desired response returned?
return is_array($desired) ? in_array(substr($this->last_message, 0, 3), $desired) : substr($this->last_message, 0, 3) == $desired;
}
It took me hours to debug this and to be able to install packages in my server (with safemode=on), I hope someone finds it useful.
Keep up the good work,
Alkis
Thanks for the post. I will add it to the list.
I believe this has been worked on and should show up soon as a fix. I will bring it up to the developers.
Yes it was being worked on. I brought this up a while ago and the devs where working on it with me since Mac systems are one of the ones that this occurs on.
The bug is still there in SMF 2.0 RC.
My proposed fix is still valid, but the function is now in the "Class-Package.php" file.
Thx Metallica for moving this to bug reports at my request.
Hopefully being moved to here means we can have another look at it.
Added to the bug tracker
http://dev.simplemachines.org/mantis/view.php?id=3112