cvs: php-src(PHP_5_0) /ext/imap php_imap.c
| From: | Ilia Alshanetsky | Date: | Wed, 21 Jul 2004 21:57:09 +0000 |
| Subject: | cvs: php-src(PHP_5_0) /ext/imap php_imap.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-27950@lists.php.net to get a copy of this message | ||
iliaa Wed Jul 21 17:57:09 2004 EDT
Modified files: (Branch: PHP_5_0)
/php-src/ext/imap php_imap.c
Log:
MFH: Fixed bug #29209 (imap_fetchbody() doesn't check message index).
http://cvs.php.net/diff.php/php-src/ext/imap/php_imap.c?r1=1.184&r2=1.184.2.1&ty=u
Index: php-src/ext/imap/php_imap.c
diff -u php-src/ext/imap/php_imap.c:1.184 php-src/ext/imap/php_imap.c:1.184.2.1
--- php-src/ext/imap/php_imap.c:1.184 Sun Jul 4 12:52:59 2004
+++ php-src/ext/imap/php_imap.c Wed Jul 21 17:57:09 2004
@@ -26,7 +26,7 @@
| PHP 4.0 updates: Zeev Suraski <zeev@zend.com> |
+----------------------------------------------------------------------+
*/
-/* $Id: php_imap.c,v 1.184 2004/07/04 16:52:59 iliaa Exp $ */
+/* $Id: php_imap.c,v 1.184.2.1 2004/07/21 21:57:09 iliaa Exp $ */
#define IMAP41
@@ -182,6 +182,12 @@
/* True globals, no need for thread safety */
static int le_imap;
+#define PHP_IMAP_CHECK_MSGNO(msgindex) \
+ if ((msgindex < 1) || ((unsigned) msgindex > imap_le_struct->imap_stream->nmsgs)) { \
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad message number"); \
+ RETURN_FALSE; \
+ } \
+
/* {{{ mail_close_it
*/
static void mail_close_it(zend_rsrc_list_entry *rsrc TSRMLS_DC)
@@ -1529,11 +1535,8 @@
convert_to_string_ex(defaulthost);
}
- if (!Z_LVAL_PP(msgno) || Z_LVAL_PP(msgno) < 1 || (unsigned) Z_LVAL_PP(msgno) >
imap_le_struct->imap_stream->nmsgs) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad message number");
- RETURN_FALSE;
- }
-
+ PHP_IMAP_CHECK_MSGNO(Z_LVAL_PP(msgno));
+
if (mail_fetchstructure(imap_le_struct->imap_stream, Z_LVAL_PP(msgno), NIL)) {
cache = mail_elt(imap_le_struct->imap_stream, Z_LVAL_PP(msgno));
} else {
@@ -1779,10 +1782,7 @@
} else {
msgindex = Z_LVAL_PP(msgno);
}
- if ((msgindex < 1) || ((unsigned) msgindex > imap_le_struct->imap_stream->nmsgs)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad message number");
- RETURN_FALSE;
- }
+ PHP_IMAP_CHECK_MSGNO(msgindex);
mail_fetchstructure_full(imap_le_struct->imap_stream, Z_LVAL_PP(msgno), &body , myargc == 3
? Z_LVAL_PP(flags) : NIL);
@@ -1817,6 +1817,8 @@
convert_to_long_ex(flags);
}
+ PHP_IMAP_CHECK_MSGNO(Z_LVAL_PP(msgno));
+
body = mail_fetchbody_full(imap_le_struct->imap_stream, Z_LVAL_PP(msgno), Z_STRVAL_PP(sec),
&len, myargc==4 ? Z_LVAL_PP(flags) : NIL);
if (!body) {
@@ -2512,10 +2514,7 @@
msgindex = Z_LVAL_PP(msgno);
}
- if ((msgindex < 1) || ((unsigned) msgindex > imap_le_struct->imap_stream->nmsgs)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad message number");
- RETURN_FALSE;
- }
+ PHP_IMAP_CHECK_MSGNO(msgindex);
RETVAL_STRING(mail_fetchheader_full(imap_le_struct->imap_stream, Z_LVAL_PP(msgno), NIL, NIL,
(myargc == 3 ? Z_LVAL_PP(flags) : NIL)), 1);
}