php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76618 segfault on imap_reopen
Submitted: 2018-07-13 07:54 UTC Modified: 2018-07-16 20:30 UTC
From: slim at inbox dot lv Assigned:
Status: Analyzed Package: IMAP related
PHP Version: 7.1.19 OS: linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2018-07-13 07:54 UTC] slim at inbox dot lv
Description:
------------
php segfaults randomly on heavy imap_reopen usage with 7.x branches.
From phpng-upgrading docs it looks like on failed mail_open() streamind should be closed, not deleted


Patches

php-inbox-php71-reopen-close.patch (last revision 2018-07-13 07:54 UTC) by slim at inbox dot lv)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-07-13 11:37 UTC] cmb@php.net
-Status: Open +Status: Verified
 [2018-07-13 11:37 UTC] cmb@php.net
Simple reproducer without mailserver:

<?php
$imap = imap_open('~/good-mailbox', '', '', 0);
var_dump($imap);
$foo = $imap;
var_dump(imap_num_msg($imap));
var_dump(imap_reopen($imap, '~/bad-mailbox'));
var_dump(imap_num_msg($imap));
 [2018-07-16 12:55 UTC] kalle@php.net
-Status: Verified +Status: Assigned -Assigned To: +Assigned To: nikic
 [2018-07-16 12:55 UTC] kalle@php.net
Nikita, is this the correct fix (being our presidental php-ng expert)?
 [2018-07-16 14:15 UTC] cmb@php.net
It seems to me the correct fix would be to remove imap_reopen().
Consider how `bool freopen($res)` would work.
 [2018-07-16 20:30 UTC] nikic@php.net
-Status: Assigned +Status: Analyzed -Assigned To: nikic +Assigned To:
 [2018-07-16 20:30 UTC] nikic@php.net
@kalle: Patch looks good to me.
 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Thu Oct 18 19:01:26 2018 UTC