Bug #80800 [Asn->Csd]: imap_open() fails when the flags parameter includes CL_EXPUNGE
| From: | girgias@php.net | Date: | Sat, 27 Feb 2021 13:15:02 +0000 |
| Subject: | Bug #80800 [Asn->Csd]: imap_open() fails when the flags parameter includes CL_EXPUNGE | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-232417@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80800&edit=1
ID: 80800
Updated by: girgias@php.net
Reported by: phplist at dcameron dot me dot uk
Summary: imap_open() fails when the flags parameter includes
CL_EXPUNGE
-Status: Assigned
+Status: Closed
Type: Bug
Package: IMAP related
Operating System: Linux Mint
PHP Version: 8.0.2
Assigned To: girgias
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of girgias
Revision: http://git.php.net/?p=php-src.git;a=commit;h=1ee6aad248117312fdc9ff7edc3ddd7bd5203d79
Log: Fix Bug #80800 imap_open() fails when the flags parameter includes CL_EXPUNGE
Previous Comments:
------------------------------------------------------------------------
[2021-02-25 15:49:02] phplist at dcameron dot me dot uk
Description:
------------
Code to open a mailbox using imap_open() works fine for php 7 and earlier but fails with php 8. This
is when the fourth parameter is set to CL_EXPUNGE. If any other valid flag is used, such as
OP_DEBUG, then the open is successful.
IMAP c-Client Version 2007f
Looking at the c code for the imap extension, php 8 has some extra validation of the flags
parameter. This is the line that throws the error
if (flags && ((flags & ~(OP_READONLY | OP_ANONYMOUS | OP_HALFOPEN | CL_EXPUNGE |
OP_DEBUG | OP_SHORTCACHE
| OP_SILENT | OP_PROTOTYPE | OP_SECURE)) != 0)) {
https://github.com/php/php-src/commit/25569679aae88af948ee0d28c24aa2b2d1ec5398#diff-e7d2d77c4b01ac1a055eaa7b5bb2b8bb52cc3a04dc849130078104aa90602e49R716
The use of the C constant CL_EXPUNGE looks possibly wrong. That is the value provided by the c
client library, not the PHP value. The flags parameter will have the PHP constant value 32768 and it
is that which should be tested.
A few lines down the flags parameter is tested for PHP_EXPUNGE and then that bit is cleared.
if (flags & PHP_EXPUNGE) {
https://github.com/php/php-src/commit/25569679aae88af948ee0d28c24aa2b2d1ec5398#diff-e7d2d77c4b01ac1a055eaa7b5bb2b8bb52cc3a04dc849130078104aa90602e49R728
Test script:
---------------
// can use any server because it doesn't get as far as connecting
$link = imap_open('{imap.gmail.com:993}INBOX', 'zzzxxxx', 'asasasasa',
CL_EXPUNGE);
Expected result:
----------------
The mailbox should be opened and the program continue executing.
Actual result:
--------------
[Thu Feb 25 15:27:24.083079 2021] [php:error] [pid 22835] [client 127.0.0.1:33586] PHP Fatal error:
Uncaught ValueError: imap_open(): Argument #4 ($flags) must be a bitmask of the OP_* constants, and
CL_EXPUNGE in
/home/duncan/Development/GitHub/phplist3/public_html/lists/admin/processbounces.php:367
Stack trace:
#0 /home/duncan/Development/GitHub/phplist3/public_html/lists/admin/processbounces.php(367):
imap_open()
#1 /home/duncan/Development/GitHub/phplist3/public_html/lists/admin/processbounces.php(497):
processPop()
#2 /home/duncan/Development/GitHub/phplist3/public_html/lists/admin/index.php(752):
include('...')
#3 {main}
thrown in /home/duncan/Development/GitHub/phplist3/public_html/lists/admin/processbounces.php on
line 367, referer: http://strontian/lists/admin/?page=bouncemgt&tk=6b1ba5b4ffee3a1a0d1d550a0290cd5f
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80800&edit=1