cvs: php4 /ext/imap php_imap.c php_imap.h
| From: | Jani Taskinen | Date: | Tue, 17 Oct 2000 15:42:05 +0000 |
| Subject: | cvs: php4 /ext/imap php_imap.c php_imap.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-2091@lists.php.net to get a copy of this message | ||
sniper Tue Oct 17 08:42:05 2000 EDT
Modified files:
/php4/ext/imap php_imap.c php_imap.h
Log:
Index: php4/ext/imap/php_imap.c
diff -u php4/ext/imap/php_imap.c:1.45 php4/ext/imap/php_imap.c:1.46
--- php4/ext/imap/php_imap.c:1.45 Sat Sep 9 13:26:15 2000
+++ php4/ext/imap/php_imap.c Tue Oct 17 08:42:05 2000
@@ -25,7 +25,7 @@
| PHP 4.0 updates: Zeev Suraski <zeev@zend.com> |
+----------------------------------------------------------------------+
*/
-/* $Id: php_imap.c,v 1.45 2000/09/09 20:26:15 chagenbu Exp $ */
+/* $Id: php_imap.c,v 1.46 2000/10/17 15:42:05 sniper Exp $ */
#define IMAP41
@@ -368,8 +368,8 @@
static void php_imap_init_globals(zend_imap_globals *imap_globals)
{
- imap_globals->imap_user[0] = 0;
- imap_globals->imap_password[0] = 0;
+ imap_globals->imap_user=NIL;
+ imap_globals->imap_password=NIL;
imap_globals->imap_folders=NIL;
imap_globals->imap_sfolders=NIL;
imap_globals->imap_alertstack=NIL;
@@ -600,10 +600,7 @@
void imap_do_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
{
- zval **mailbox;
- zval **user;
- zval **passwd;
- zval **options;
+ zval **mailbox, **user, **passwd, **options;
MAILSTREAM *imap_stream;
pils *imap_le_struct;
long flags=NIL;
@@ -632,9 +629,10 @@
flags ^= PHP_EXPUNGE;
}
}
- strcpy(IMAPG(imap_user), Z_STRVAL_PP(user));
- strcpy(IMAPG(imap_password), Z_STRVAL_PP(passwd));
+ IMAPG(imap_user) = estrndup(Z_STRVAL_PP(user), Z_STRLEN_PP(user));
+ IMAPG(imap_password) = estrndup(Z_STRVAL_PP(passwd), Z_STRLEN_PP(passwd));
+
#ifdef OP_RELOGIN
/* AJS: persistent connection handling */
/* Cannot use a persistent connection if we cannot parse
@@ -765,6 +763,9 @@
} else {
#endif
imap_stream = mail_open(NIL, Z_STRVAL_PP(mailbox), flags);
+ efree(IMAPG(imap_user));
+ efree(IMAPG(imap_password));
+
if (imap_stream == NIL) {
php_error(E_WARNING, "Couldn't open stream %s\n", (*mailbox)->value.str.val);
RETURN_FALSE;
@@ -1885,7 +1886,7 @@
PHP_FUNCTION(imap_fetchstructure)
{
zval **streamind, **msgno, **flags;
- int ind, ind_type;
+ int ind, ind_type, msgindex;
pils *imap_le_struct;
BODY *body;
int myargc=ZEND_NUM_ARGS();
@@ -1912,8 +1913,21 @@
php_error(E_WARNING, "Unable to find stream pointer");
RETURN_FALSE;
}
-
- mail_fetchstructure_full(imap_le_struct->imap_stream, Z_LVAL_PP(msgno), &body ,myargc == 3
? Z_LVAL_PP(flags) : NIL);
+
+ 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;
+ }
+
+ mail_fetchstructure_full(imap_le_struct->imap_stream, msgindex, &body ,myargc == 3 ?
Z_LVAL_PP(flags) : NIL);
if (!body) {
php_error(E_WARNING, "No body information available");
@@ -4074,19 +4088,19 @@
#if HAVE_IMSP
if (*mb->service && strcmp(mb->service, "imsp") == 0) {
if (*mb->user) {
- strcpy(user, mb->user);
+ strncpy(user, mb->user, MAILTMPLEN);
} else {
- strcpy(user, imsp_user);
+ strncpy(user, imsp_user, MAILTMPLEN);
}
- strcpy (pwd, imsp_password);
+ strncpy (pwd, imsp_password, MAILTMPLEN);
} else {
#endif
if (*mb->user) {
- strcpy (user,mb->user);
+ strncpy (user,mb->user, MAILTMPLEN);
} else {
- strcpy (user, IMAPG(imap_user));
+ strncpy (user, IMAPG(imap_user), MAILTMPLEN);
}
- strcpy (pwd, IMAPG(imap_password));
+ strncpy (pwd, IMAPG(imap_password), MAILTMPLEN);
#if HAVE_IMSP
}
#endif
Index: php4/ext/imap/php_imap.h
diff -u php4/ext/imap/php_imap.h:1.4 php4/ext/imap/php_imap.h:1.5
--- php4/ext/imap/php_imap.h:1.4 Sun Jul 2 17:41:15 2000
+++ php4/ext/imap/php_imap.h Tue Oct 17 08:42:05 2000
@@ -140,8 +140,8 @@
PHP_FUNCTION(imap_mime_header_decode);
ZEND_BEGIN_MODULE_GLOBALS(imap)
- char imap_user[80];
- char imap_password[80];
+ char *imap_user;
+ char *imap_password;
STRINGLIST *imap_folders;
STRINGLIST *imap_sfolders;
STRINGLIST *imap_alertstack;