Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.3.2

Bug #7197 getScript() truncates long scripts
Submitted: 2006-03-24 09:56 UTC Modified: 2006-05-21 01:37 UTC
From: bluecamel at imap dot cc Assigned: amistry
Status: Closed Package: Net_Sieve (version 1.1.2)
PHP Version: 4.3.9 OS: Linux
Roadmaps: (Not assigned)    
Subscription  


 [2006-03-24 09:56 UTC] bluecamel at imap dot cc (Scott Russell)
Description: ------------ The default max sieve script size in Cyrus 2.3.1 is 32k. Net::Socket::read() called by Net::Sieve::_doCmd() uses php fread() to read a specific string length from the timsieved socket. If the first packet returned by timsieved is smaller than the string size requested by fread() then the remainder of the string was being truncated. The result is large scripts (27k+ in my case) are truncated at about 11k. This is correct behavior according to the php fread() manual: fread() reads up to length bytes from the file pointer referenced by handle. Reading stops when up to length bytes have been read, EOF (end of file) is reached, (for network streams) when a packet becomes available, or (after opening userspace stream) when 8192 bytes have been read whichever comes first. Test script: --------------- // connect to sieve if ( PEAR::isError( $sieve = my_sieve_connect($euser) ) ) { return $sieve; } $sieve->setDebug(TRUE); $result = $sieve->getScript($large_script); $sieve->disconnect(); var_dump($result);

Comments

 [2006-03-24 10:00 UTC] bluecamel at imap dot cc
Possible patch. Note the line wraps! Also available at http://files.bluecamel.imap.cc/ --- Sieve.php.orig 2006-03-23 19:29:39.000000000 -0500 +++ Sieve.php 2006-03-24 09:15:47.000000000 -0500 @@ -993,7 +993,11 @@ } elseif (preg_match('/^{([0-9]+)\+?}/i', $line, $matches)) { // Matches String Responses. //$line = str_replace("\r\n", ' ', $this->_sock->read($matches[1] + 2 )); - $line = $this->_sock->read($matches[1] + 2 ); + $str_size = $matches[1] + 2; + $line = ''; + while (strlen($line) != $str_size) { + $line .= $this->_sock->read($str_size - strlen($line)); + } if($this->_debug){ echo "S:$line\n"; }
 [2006-03-24 10:45 UTC] amistry at php dot net (Anish Mistry)
I'll take a look at it this weekend. Thanks for the report.
 [2006-03-26 13:22 UTC] amistry at php dot net (Anish Mistry)
I've fixed this in the CVS with a slightly modified version of your patch. Please test it and let me know. Thanks.
 [2006-04-01 13:27 UTC] amistry at php dot net (Anish Mistry)
Any news? I'd like to cut a release this weekend and want to make sure this works for you. Thanks.
 [2006-04-19 20:23 UTC] bluecamel at imap dot cc
Sorry about that. I'm a bit clueless on pear setup so am unsure _where_ the CVS repo might be. I assume it's anonymous pserver. What is CVSROOT for it?
 [2006-04-19 22:26 UTC] amistry at php dot net (Anish Mistry)
http://www.php.net/anoncvs.php You want to checkout pear/Net_Sieve
 [2006-05-21 01:37 UTC] amistry at php dot net (Anish Mistry)
Thank you for your bug report. This issue has been fixed in the latest released version of the package, which you can download at http://pear.php.net/get/Net_Sieve