Page 1 of 1

Wrong file pointer at mime_parser.php

Posted: Wed Apr 13, 2022 10:53 pm
by BRStuff
Script URL: inc/mail/mime_parser.php
Version of script: 3.2.5
Hosting company:
URL of phpinfo.php:
URL of session_test.php:
What terms did you try when SEARCHING for a solution:

Write your message below:

In function ReadMessageBody line 2075 "fclose($stream);" uses a wrong file pointer. Must be $file.

Code: Select all

Function ReadMessageBody($message, &$body, $prefix)
{
	if(IsSet($message[$prefix]))
		$body = $message[$prefix];
	elseif(IsSet($message[$prefix.'File']))
	{
		$path = $message[$prefix.'File'];
		if(!($file = @fopen($path, 'rb')))
			return($this->SetPHPError('could not open the message body file '.$path));
		for($body = '', $end = 0;!$end;)
		{
			if(!($data = @fread($file, $this->message_buffer_length)))
			{
				$this->SetPHPError('Could not open the message body file '.$path);
				fclose($stream);
				return(0);
			}
			$end=feof($file);
			$body.=$data;
		}
		fclose($file);
	}
	else
		$body = '';
	return(1);
}
I found the bug because I had a mail that the parser, when reading the cache file, opened but couldn't do the fread. With file_get_contents it can open and read. Does anyone have any idea what the problem could be?

Re: Wrong file pointer at mime_parser.php

Posted: Fri Apr 15, 2022 11:30 am
by Klemen
That's a third party library we use, but yes, it does look like an error, should be $file.

Not sure why fread wouldn't work. You can try removing @ before fread and turning Debug mode ON in Hesk settings, then see if you get any error messages or notices.