php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #3333 PHP crashes wen I open an empty mailbox
Submitted: 2000-01-27 15:57 UTC Modified: 2001-02-10 15:26 UTC
From: sutter at mygale dot org Assigned:
Status: Closed Package: IMAP related
PHP Version: 3.0.14 OS: NT
Private report: No CVE-ID: None
 [2000-01-27 15:57 UTC] sutter at mygale dot org
The following code crashes PHP when my mailbox is empty !

<html>
<?php 

$MAILSERVER= "{pop.mail.com/pop3}"; 
$link=imap_open($MAILSERVER,"login", "pass"); 
$headers=imap_headers($link); 

for($x=1; $x < count($headers); $x++) { 
    $idx=($x-1); 
    echo  "<a href=\"view.php3?num=$x\">$headers[$idx]</a><br>"; 
} 

?>
</html>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-01-28 11:56 UTC] joey at cvs dot php dot net
Define "crash". Does httpd dump core? If so, can you provide a backtrace?
 [2000-02-29 09:57 UTC] hholzgra at cvs dot php dot net
the POP3 and IMAP drivers in c-client treat
an empty mailbox slightly different here

both will log this event with mm_log,
but while the imap driver logs it just for info
with type NIL, the pop driver issues a WARN

this leads to a 'fatal error' message in PHP,
but it should not crash 

you may want to check the presence of messages
with imap_check() or imap_status() before
calling imap_headers()

PS: you have an off-by-one error in your example,
    it should read <= count() instead of < count()
    in the for-statement
 [2000-02-29 14:20 UTC] chagenbu at cvs dot php dot net
here's a backtrace for this one as well. Once again, it
doesn't give me the slightest clue as to what's going wrong.

Program received signal SIGSEGV, Segmentation fault.
0x40231555 in zend_plist_delete () at zend_list.c:204
204     }
(gdb) bt
#0  0x40231555 in zend_plist_delete () at zend_list.c:204
#1  0x40377ba0 in __DTOR_END__ () from /usr/lib/apache/1.3/libphp4.so
#2  0x4023172b in zend_fetch_resource () at zend_list.c:204
#3  0x4022e063 in add_index_unset () at zend_API.c:774
#4  0x4020b06f in php_init_config () at configuration-parser.y:138
#5  0x8051bdc in run_cleanups (c=0x80f7a14) at alloc.c:1939
#6  0x8050c54 in ap_clear_pool (a=0x80f598c) at alloc.c:682
#7  0x8050cb4 in ap_destroy_pool (a=0x80f598c) at alloc.c:712
#8  0x8050c40 in ap_clear_pool (a=0x80a556c) at alloc.c:675
#9  0x805c09f in child_main (child_num_arg=0) at http_main.c:3845
#10 0x805c5cc in make_child (s=0x8099c24, slot=0, now=951851762)
    at http_main.c:4235
#11 0x805c6e9 in startup_children (number_to_start=5) at http_main.c:4317
#12 0x805cb9b in standalone_main (argc=2, argv=0xbffff7a4) at http_main.c:4605
#13 0x805d24d in main (argc=2, argv=0xbffff7a4) at http_main.c:4933

 [2000-02-29 15:34 UTC] chagenbu at cvs dot php dot net
The test case for this can be reduced to:

<html>
<?php
$MAILSERVER= "{pop.mail.com/pop3}";
$link=imap_open($MAILSERVER,"login", "pass");
?>
</html>


Same cleanup crash. Anyone have an idea what's different
about empty pop3 mailboxes that seem to close the resource
early?
 [2000-02-29 15:37 UTC] chagenbu at cvs dot php dot net
I should also add that this is reproducible on Linux, so it's not just an NT problem.
 [2000-08-01 21:32 UTC] hholzgra@php.net
is this reproduceable with latest php and c-client versions?

if so - what's the pop server you are using?

i cannot reproduce this ...
 [2001-02-10 15:26 UTC] jimw@php.net
no feedback, closing.
 [2020-11-24 16:47 UTC] lucywilliamsusa at rediffmail dot com
http://www.findbodyinshape.net/phenq-review.html

<a href=" http://www.findbodyinshape.net/   ">findbodyinshape.net</a>
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Dec 01 23:03:34 2021 UTC