From: mkz at terra dot com dot br
Operating system: Windows XP Professional
PHP version: 5.2.4
PHP Bug Type: Strings related
Bug description: FGETS Crash using FSOCKOPEN
Description:
------------
Fgets function cause a fatal error in script.
Reproduce code:
---------------
<?
class Smtp{
//Creditos: Red neck adaptada por Micael Vianna (http://aiatola.net)
var $conn;
var $user;
var $pass;
var $html;
var $debug = true;
var $logado = false;
var $erro;
function Smtp($host,$porta){
$this->conn = fsockopen($host, $porta, $errno, $errstr, 30);
$this->Put("EHLO $host");
}
function Auth(){
$this->Put("AUTH LOGIN");
$this->Put(base64_encode($this->user));
$this->Put(base64_encode($this->pass));
}
function Send($toName, $to, $fromName, $from, $replyTo, $subject, $msg)
{
if(isset($this->conn))
{
// se nao estiver logado, loga
if (!$this->logado)
{
$this->Auth();
$this->logado = true;
}
$this->Put("MAIL FROM: <" . $from.">");
$this->Put("RCPT TO: <" . $to.">");
$this->Put("DATA");
$this->Put($this->toHeader($toName."<".$to.">",
$fromName."<".$from.">",
$fromName."<".$replyTo.">", $subject));
$this->Put("\r\n");
$this->Put($msg);
$this->Put(".");
$i = 0;
$dados = $this->conn;
}
else
return false;
while (!feof ($dados) || $this->conn)
{
flush();
$buffer = fgets($this->conn, 4096);
}
}
function Put($value){
return fputs($this->conn, $value . "\r\n");
echo $this->conn;
}
function getRetorno($valor)
{
return $valor{0}.$valor{1}.$valor{2};
}
function toHeader($to, $from, $replyTo, $subject){
$header = "Message-Id: <". date('YmdHis').".". md5(microtime()).".".
strtoupper($from) ."> \r\n";
$header .= "From: ". $from . " \r\n";
$header .= "To: ".$to." \r\n";
$header .= "Reply-To: ".$replyTo."\r\n";
$header .= "Subject: ".$subject." \r\n";
$header .= "Date: ". date('D, d M Y H:i:s O') ." \r\n";
$header .= "Content-Type: text/html; charset=iso-8859-1 \r\n";
$header .= "X-MSMail-Priority: High \r\n";
return $header;
}
function Close(){
$this->Put("QUIT");
return fclose($this->conn);
}
function getErro()
{
return $this->erro;
}
}
set_time_limit(10);
require_once('../modulos/addons/smtp/class.smtp.php');
$smtp = new Smtp("YOUR SMTP SERVER",25);
$smtp->debug = false;
$smtp->user = "YOUR SMTP USERNAME";
$smtp->pass = "YOUR SMTP PASSWORD";
if ($smtp->Send('micael','YOUR EMAIL','fulano','YOUR
EMAIL','REPLY','Super
promo��o',"<html><body><table><tr><td>oi</td><td>tudo</td></tr></table></body></html>"))
{ echo "ok"; }
else
{
echo "ERRO".$smtp->getErro();
}
$smtp->Close();
?>
Expected result:
----------------
List all status from SMTP connect :)
Actual result:
--------------
Fatal error: Maximum execution time of 10 seconds exceeded line 46
--
Edit bug report at http://bugs.php.net/?id=42982&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=42982&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=42982&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=42982&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=42982&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=42982&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=42982&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=42982&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=42982&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=42982&r=support
Expected behavior: http://bugs.php.net/fix.php?id=42982&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=42982&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=42982&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=42982&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=42982&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=42982&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=42982&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=42982&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=42982&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=42982&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=42982&r=mysqlcfg