iliaa Tue Mar 27 00:13:09 2007 UTC
Modified files: (Branch: PHP_5_2)
/php-src/ext/standard mail.c
Log:
Fixed MOPB-33-2007:PHP mail() Message ASCIIZ Byte Truncation
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/mail.c?r1=1.87.2.1.2.2&r2=1.87.2.1.2.3&diff_format=u
Index: php-src/ext/standard/mail.c
diff -u php-src/ext/standard/mail.c:1.87.2.1.2.2
php-src/ext/standard/mail.c:1.87.2.1.2.3
--- php-src/ext/standard/mail.c:1.87.2.1.2.2 Thu Jan 25 00:26:51 2007
+++ php-src/ext/standard/mail.c Tue Mar 27 00:13:09 2007
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: mail.c,v 1.87.2.1.2.2 2007/01/25 00:26:51 iliaa Exp $ */
+/* $Id: mail.c,v 1.87.2.1.2.3 2007/03/27 00:13:09 iliaa Exp $ */
#include <stdlib.h>
#include <ctype.h>
@@ -55,6 +55,14 @@
continue;
\
}
\
+#define MAIL_ASCIIZ_CHECK(str, len) \
+ p = str; \
+ e = p + len; \
+ while (p = memchr(p, '\0', (e - p))) { \
+ *p = ' '; \
+ } \
+
+
/* {{{ proto int ezmlm_hash(string addr)
Calculate EZMLM list hash value. */
PHP_FUNCTION(ezmlm_hash)
@@ -88,6 +96,7 @@
int subject_len, extra_cmd_len, i;
char *force_extra_parameters = INI_STR("mail.force_extra_parameters");
char *to_r, *subject_r;
+ char *p, *e;
if (PG(safe_mode) && (ZEND_NUM_ARGS() == 5)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "SAFE MODE
Restriction in effect. The fifth parameter is disabled in SAFE MODE.");
@@ -104,6 +113,17 @@
return;
}
+ /* ASCIIZ check */
+ MAIL_ASCIIZ_CHECK(to, to_len);
+ MAIL_ASCIIZ_CHECK(subject, subject_len);
+ MAIL_ASCIIZ_CHECK(message, message_len);
+ if (headers) {
+ MAIL_ASCIIZ_CHECK(headers, headers_len);
+ }
+ if (extra_cmd) {
+ MAIL_ASCIIZ_CHECK(extra_cmd, extra_cmd_len);
+ }
+
if (to_len > 0) {
to_r = estrndup(to, to_len);
for (; to_len; to_len--) {
@@ -150,7 +170,7 @@
} else if (extra_cmd) {
extra_cmd = php_escape_shell_cmd(extra_cmd);
}
-
+
if (php_mail(to_r, subject_r, message, headers, extra_cmd TSRMLS_CC)) {
RETVAL_TRUE;
} else {
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php