Hi,

in the last 2 days our horde logs have been flooded with the following ERRORS:

2022-08-29T14:45:24+02:00 WARN: HORDE [imp] PHP ERROR: rewind() expects parameter 1 to be resource, null given [pid 1776546 on line 3166 of "/var/www/html/horde/imp/lib/Compose.php"] 2022-08-29T14:45:24+02:00 WARN: HORDE [imp] PHP ERROR: feof() expects parameter 1 to be resource, null given [pid 1776546 on line 3168 of "/var/www/html/horde/imp/lib/Compose.php"] 2022-08-29T14:45:24+02:00 WARN: HORDE [imp] PHP ERROR: fread() expects parameter 1 to be resource, null given [pid 1776546 on line 3169 of "/var/www/html/horde/imp/lib/Compose.php"] 2022-08-29T14:45:24+02:00 WARN: HORDE [imp] PHP ERROR: feof() expects parameter 1 to be resource, null given [pid 1776546 on line 3168 of "/var/www/html/horde/imp/lib/Compose.php"] 2022-08-29T14:45:24+02:00 WARN: HORDE [imp] PHP ERROR: fread() expects parameter 1 to be resource, null given [pid 1776546 on line 3169 of "/var/www/html/horde/imp/lib/Compose.php"] 2022-08-29T14:45:24+02:00 WARN: HORDE [imp] PHP ERROR: feof() expects parameter 1 to be resource, null given [pid 1776546 on line 3168 of "/var/www/html/horde/imp/lib/Compose.php"] 2022-08-29T14:45:24+02:00 WARN: HORDE [imp] PHP ERROR: fread() expects parameter 1 to be resource, null given [pid 1776546 on line 3169 of "/var/www/html/horde/imp/lib/Compose.php"] 2022-08-29T14:45:24+02:00 WARN: HORDE [imp] PHP ERROR: feof() expects parameter 1 to be resource, null given [pid 1776546 on line 3168 of "/var/www/html/horde/imp/lib/Compose.php"] 2022-08-29T14:45:24+02:00 WARN: HORDE [imp] PHP ERROR: fread() expects parameter 1 to be resource, null given [pid 1776546 on line 3169 of "/var/www/html/horde/imp/lib/Compose.php"]

These errors are in the function addAttachmentFromPart($part)
I don't know why the stream is null, but I found an old thread regarding the same problem in renderMIMEPart (horde/imp/lib/Contents.php) https://imp.horde.narkive.com/u1CD9QAA/rendermimepart-php-error

where a sanity check had been added by Michael Slusarz

I would suggest an similar check


  public function addAttachmentFromPart($part)
  {
        /* Extract the data from the Horde_Mime_Part. */
        $atc_file = Horde::getTempFile('impatt');

   $stream = $part->getContents(array(
            'stream' => true
        ));
+  if (!is_null($stream)) {
        rewind($stream);
        $dest_handle = fopen($atc_file, 'w+b');
        while (!feof($stream)) {
            fwrite($dest_handle, fread($stream, 1024));
        }
        fclose($dest_handle);
        $size = ftell($stream);
+   }
    if ($size === false) {
throw new IMP_Compose_Exception(sprintf(_("Could not attach %s to the message."), $part->getName()));
    }

    return $this->_addAttachment(
            $atc_file,
            $size,
            $part->getName(true),
            $part->getType()
        );
  }

But I am unsure if the Exception should go into the new if-Block and we throw a new IMP_Compose_Exception or
the "$size === false" would also be triggered if $stream is null.

Kind Regards

   Michael Menge



--------------------------------------------------------------------------------
Michael Menge                          Tel.: (49) 7071 / 29-70316
Universität Tübingen                   Fax.: (49) 7071 / 29-5912
Zentrum für Datenverarbeitung mail: michael.me...@zdv.uni-tuebingen.de
Wächterstraße 76
72074 Tübingen

--
imp mailing list
Frequently Asked Questions: http://wiki.horde.org/FAQ
To unsubscribe, mail: imp-unsubscr...@lists.horde.org

Reply via email to