Bug #80800 [NEW]: imap_open() fails when the flags parameter includes CL_EXPUNGE

From: Date: Thu, 25 Feb 2021 15:49:02 +0000
Subject: Bug #80800 [NEW]: imap_open() fails when the flags parameter includes CL_EXPUNGE
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-232388@lists.php.net to get a copy of this message
From: phplist at dcameron dot me dot uk Operating system: Linux Mint PHP version: 8.0.2 Package: IMAP related Bug Type: Bug Bug description:imap_open() fails when the flags parameter includes CL_EXPUNGE 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 bug report at https://bugs.php.net/bug.php?id=80800&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=80800&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=80800&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=80800&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=80800&r=needscript Try newer version: https://bugs.php.net/fix.php?id=80800&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=80800&r=support Expected behavior: https://bugs.php.net/fix.php?id=80800&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=80800&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=80800&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=80800&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=80800&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=80800&r=dst IIS Stability: https://bugs.php.net/fix.php?id=80800&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=80800&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=80800&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=80800&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=80800&r=mysqlcfg

« previous php.bugs (#232388) next »