ID: 44594
Updated by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
-Status: Open
+Status: Assigned
Bug Type: IMAP related
Operating System: Windows XP
PHP Version: 5.2CVS-2008-04-01 (snap)
-Assigned To:
+Assigned To: iliaa
Previous Comments:
------------------------------------------------------------------------
[2008-04-01 15:54:57] [EMAIL PROTECTED]
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));
?>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=44594&edit=1