diff options
author | George Peter Banyard <girgias@php.net> | 2020-11-30 04:48:17 +0000 |
---|---|---|
committer | George Peter Banyard <girgias@php.net> | 2020-11-30 14:08:31 +0000 |
commit | 0076b47326e53d98b5df56c5f970b2b5cc3d9b6d (patch) | |
tree | d92e622f6edf87233a0328acae7da9e86cfdabb9 /ext/imap/php_imap.c | |
parent | a55402d07c12bb2eda4a41e4fc4a20d49ef17142 (diff) | |
download | php-git-0076b47326e53d98b5df56c5f970b2b5cc3d9b6d.tar.gz |
Fix Bug #80438: imap_msgno() incorrectly warns and return false on valid UIDs in PHP 8.0.0
Checking for a valid Unique ID (UID) cannot use the convenience macro as they might
be larger than the message number which has for maximum value the total number of
current messages available in the mailbox.
Diffstat (limited to 'ext/imap/php_imap.c')
-rw-r--r-- | ext/imap/php_imap.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/ext/imap/php_imap.c b/ext/imap/php_imap.c index c561a5e72c..023795fd8c 100644 --- a/ext/imap/php_imap.c +++ b/ext/imap/php_imap.c @@ -2835,10 +2835,10 @@ PHP_FUNCTION(imap_uid) PHP_FUNCTION(imap_msgno) { zval *streamind; - zend_long msgno; + zend_long msg_uid; pils *imap_le_struct; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "rl", &streamind, &msgno) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "rl", &streamind, &msg_uid) == FAILURE) { RETURN_THROWS(); } @@ -2846,9 +2846,13 @@ PHP_FUNCTION(imap_msgno) RETURN_THROWS(); } - PHP_IMAP_CHECK_MSGNO(msgno, 2); + /* Do NOT use the PHP_IMAP_CHECK_MSGNO() macro as UID cannot be checked for their upper bound. */ + if (msg_uid < 1) { + zend_argument_value_error(2, "must be greater than 0"); + RETURN_THROWS(); + } - RETURN_LONG(mail_msgno(imap_le_struct->imap_stream, msgno)); + RETURN_LONG(mail_msgno(imap_le_struct->imap_stream, msg_uid)); } /* }}} */ |