diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2020-10-13 16:20:55 +0200 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2020-10-13 19:37:05 +0200 |
commit | db8bf0a9e07f906ad5d771142e5873688aff8033 (patch) | |
tree | 2121380a344f57eb945e82d73bb3c7fe63e7f2df /ext | |
parent | 2d01a89ad1a7ff2b512f1c0e7377715c96150a35 (diff) | |
download | php-git-db8bf0a9e07f906ad5d771142e5873688aff8033.tar.gz |
Fix #64076: imap_sort() does not return FALSE on failure
If unsupported `$search_criteria` are passed to `imap_sort()`, the
function returns an empty array, but there is also an error on the
libc-client error stack ("Unknown search criterion: UNSUPPORTED
(errflg=2)"). If, on the other hand, unsupported `$criteria` or
unsupported `$flags` are passed, the function returns `false`. We
solve this inconsistency by returning `false` for unsupported
`$search_criteria` as well.
Closes GH-6332.
Diffstat (limited to 'ext')
-rw-r--r-- | ext/imap/php_imap.c | 3 | ||||
-rw-r--r-- | ext/imap/tests/bug64076.phpt | 23 |
2 files changed, 26 insertions, 0 deletions
diff --git a/ext/imap/php_imap.c b/ext/imap/php_imap.c index a88c329b01..db144b0d49 100644 --- a/ext/imap/php_imap.c +++ b/ext/imap/php_imap.c @@ -3181,6 +3181,9 @@ PHP_FUNCTION(imap_sort) } else { spg = mail_newsearchpgm(); } + if (spg == NIL) { + RETURN_FALSE; + } mypgm = mail_newsortpgm(); mypgm->reverse = rev; diff --git a/ext/imap/tests/bug64076.phpt b/ext/imap/tests/bug64076.phpt new file mode 100644 index 0000000000..ccafcfe251 --- /dev/null +++ b/ext/imap/tests/bug64076.phpt @@ -0,0 +1,23 @@ +--TEST-- +Bug #64076 (imap_sort() does not return FALSE on failure) +--SKIPIF-- +<?php +require_once __DIR__ . '/skipif.inc'; +?> +--FILE-- +<?php +require_once __DIR__ . '/imap_include.inc'; +$stream = setup_test_mailbox('', 2); +imap_errors(); // clear error stack +var_dump(imap_sort($stream, SORTFROM, 0, 0, 'UNSUPPORTED SEARCH CRITERIUM')); +var_dump(imap_errors() !== false); +?> +--CLEAN-- +<?php +require_once __DIR__ . '/clean.inc'; +?> +--EXPECT-- +Create a temporary mailbox and add 2 msgs +.. mailbox '{127.0.0.1:143/norsh}INBOX.phpttest' created +bool(false) +bool(true) |