PDA

View Full Version : maximum string length 8KB? ?????


domdorn
02-18-2010, 02:30 PM
Hi,

I'm investigating why the forum software from phorum.org does not work on my system and found a readfile method

function phorum_read_file($file)
{
// Check if the file exists.
if (! file_exists($file)) trigger_error(
"phorum_get_file_contents: file \"" . htmlspecialchars($file) . "\" " .
"does not exist",
E_USER_ERROR
);

// In case we're handling a zero byte large file, we don't read it in.
// Running fread($fp, 0) gives a PHP warning.
$size = filesize($file);
if ($size == 0) return "";


// $data = readfile($file);
// return $data;
// Read in the file contents.
if (! $fp = fopen($file, "r")) trigger_error(
"phorum_get_file_contents: failed to read file " .
"\"" . htmlspecialchars($file) . "\"",
E_USER_ERROR
);
// Strip UTF-8 byte order markers from the files. These only mean
// harm for PHP scripts.
$data = '';
if ($size >= 3) {
$data = fread($fp, 3);
if ($data == "\xef\xbb\xbf") {
$data = '';
}
$size -= 3;
}
// Read the rest of the file.
if ($size > 0) {
$data .= fread($fp, $size);
}
fclose($fp);

// code inserted by me start
$realFileSize = filesize($file);
$readFileSize = 0;
mail("dominik.dorn@gmail.com",
"readfile: $file",
"realFileSize: $realFileSize \n Size of read file: $readFileSize\n\n",
"From: mymail@myhost.com");
// code inserted by me end
return $data;
}


I receive such a mail:
realFileSize: 9537
Size of read file: 8192

Quercus seems to only store 8192 bytes in a variable... how can I raise this limit?

domdorn
02-19-2010, 06:53 PM
Update: It's not a bug with the length of the value, but actually a bug in quercus fread() method.
I've created a bug here http://bugs.caucho.com/view.php?id=3894 and also provided a testcase which shows the problem.

For some reason, neither this board, nor the bugtracker let me rename the topic to
"fread() broken"
.

nam
02-21-2010, 03:34 AM
Thanks for the bug report. It appears that we're incorrectly resizing the buffers or didn't correctly use the fread length for long lengths.