cvs: php4 /ext/imap php_imap.c
| From: | Chuck Hagenbuch | Date: | Thu, 03 May 2001 19:44:42 +0000 |
| Subject: | cvs: php4 /ext/imap php_imap.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-5512@lists.php.net to get a copy of this message | ||
chagenbu Thu May 3 12:44:42 2001 EDT
Modified files:
/php4/ext/imap php_imap.c
Log:
add crash guard (valid message number check) to imap_body().
Index: php4/ext/imap/php_imap.c
diff -u php4/ext/imap/php_imap.c:1.72 php4/ext/imap/php_imap.c:1.73
--- php4/ext/imap/php_imap.c:1.72 Thu May 3 12:32:49 2001
+++ php4/ext/imap/php_imap.c Thu May 3 12:44:42 2001
@@ -25,7 +25,7 @@
| PHP 4.0 updates: Zeev Suraski <zeev@zend.com> |
+----------------------------------------------------------------------+
*/
-/* $Id: php_imap.c,v 1.72 2001/05/03 19:32:49 chagenbu Exp $ */
+/* $Id: php_imap.c,v 1.73 2001/05/03 19:44:42 chagenbu Exp $ */
#define IMAP41
@@ -1219,10 +1219,10 @@
PHP_FUNCTION(imap_body)
{
zval **streamind, **msgno, **flags;
- int ind, ind_type;
+ int ind, ind_type, msgindex;
pils *imap_le_struct;
int myargc=ZEND_NUM_ARGS();
- if (myargc <2 || myargc > 3 || zend_get_parameters_ex(myargc, &streamind, &msgno,
&flags) == FAILURE) {
+ if (myargc < 2 || myargc > 3 || zend_get_parameters_ex(myargc, &streamind, &msgno,
&flags) == FAILURE) {
ZEND_WRONG_PARAM_COUNT();
}
@@ -1238,6 +1238,20 @@
php_error(E_WARNING, "Unable to find stream pointer");
RETURN_FALSE;
}
+
+ if ((myargc == 3) && (Z_LVAL_PP(flags) & FT_UID)) {
+ /* This should be cached; if it causes an extra RTT to the
+ IMAP server, then that's the price we pay for making
+ sure we don't crash. */
+ msgindex = mail_msgno(imap_le_struct->imap_stream, Z_LVAL_PP(msgno));
+ } else {
+ msgindex = Z_LVAL_PP(msgno);
+ }
+ if ((msgindex < 1) || ((unsigned) msgindex > imap_le_struct->imap_stream->nmsgs)) {
+ php_error(E_WARNING, "Bad message number");
+ RETURN_FALSE;
+ }
+
RETVAL_STRING(mail_fetchtext_full (imap_le_struct->imap_stream, Z_LVAL_PP(msgno), NIL,
myargc==3 ? Z_LVAL_PP(flags) : NIL), 1);
}
/* }}} */
@@ -2028,11 +2042,11 @@
php_error(E_WARNING, "Unable to find stream pointer");
RETURN_FALSE;
}
-
+
if ((myargc == 3) && (Z_LVAL_PP(flags) & FT_UID)) {
- /* This should be cached; if it causes an extra RTT to the
- IMAP server, then that's the price we pay for making sure
- we don't crash. */
+ /* This should be cached; if it causes an extra RTT to the
+ IMAP server, then that's the price we pay for making
+ sure we don't crash. */
msgindex = mail_msgno(imap_le_struct->imap_stream, Z_LVAL_PP(msgno));
} else {
msgindex = Z_LVAL_PP(msgno);