|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-04-02 16:32 UTC] iliaa@php.net
[2008-04-17 08:47 UTC] jmessa@php.net
[2008-04-17 11:05 UTC] felipe@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 03:00:01 2025 UTC |
Description: ------------ When a negative integer is passed as the $n_retries argument to imap_open(), the number is passed as a signed long to the c-client function mail_parameters(), which is expecting an unsigned long to be passed on a SET_MAXLOGINTRIALS call. This results in $n_retries being set to a huge number. The problem is the the function php_imap_do_open() in ext/imap/php_imap.c. Below is a patch written by Andy Wharmby (CVS ID wharmby), it returns a warning if $n_retries is less than 0: The code as it stands is: #ifdef SET_MAXLOGINTRIALS if (myargc == 5) { convert_to_long_ex(retries); mail_parameters(NIL, SET_MAXLOGINTRIALS, (void *) Z_LVAL_PP(retries)); } #endif SOLUTION: #ifdef SET_MAXLOGINTRIALS if (myargc == 5) { convert_to_long_ex(retries); if (retries < 1) { php_error_docref(NULL TSRMLS_CC, E_WARNING ,"Retries cannot be less than 1"); RETURN_FALSE; } mail_parameters(NIL, SET_MAXLOGINTRIALS, (void *) Z_LVAL_PP(retries)); } #endif The documentation for the $n_retries argument also says that the number passed is "Number of maximum connect attempts" which is incorrect. There is always one attempt to connect, if that fails then $n_retries sets how many more attempts are made *after* the initial attempt. Reproduce code: --------------- <?php var_dump(imap_open($mailbox, $username, $password, null, -1)); ?>