Search
j0ke.net Open Build Service
>
Projects
>
home:netmax
:
rebuilds
>
php4
> php-4.3.9-CVE-2005-3883.patch
Sign Up
|
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File php-4.3.9-CVE-2005-3883.patch of Package php4
--- php-4.3.9/ext/mbstring/mbstring.c.cve3883 +++ php-4.3.9/ext/mbstring/mbstring.c @@ -3418,6 +3418,22 @@ * Sends an email message with MIME scheme */ #if HAVE_SENDMAIL +#define SKIP_LONG_HEADER_SEP_MBSTRING(str, pos) \ + if (str[pos] == '\r' && str[pos + 1] == '\n' && (str[pos + 2] == ' ' || str[pos + 2] == '\t')) { \ + pos += 3; \ + while (str[pos] == ' ' || str[pos] == '\t') { \ + pos++; \ + } \ + continue; \ + } \ + else if (str[pos] == '\n' && (str[pos + 1] == ' ' || str[pos + 1] == '\t')) { \ + pos += 2; \ + while (str[pos] == ' ' || str[pos] == '\t') { \ + pos++; \ + } \ + continue; \ + } \ + PHP_FUNCTION(mb_send_mail) { int argc, n; @@ -3433,6 +3449,8 @@ mbfl_memory_device device; /* automatic allocateable buffer for additional header */ const mbfl_language *lang; int err = 0; + char *to_r = NULL; + int to_len, i; /* initialize */ mbfl_memory_device_init(&device, 0, 0); @@ -3459,6 +3477,32 @@ convert_to_string_ex(argv[0]); if (Z_STRVAL_PP(argv[0])) { to = Z_STRVAL_PP(argv[0]); + to_len = Z_STRLEN_PP(argv[0]); + if (to_len > 0) { + to_r = estrndup(to, to_len); + for (; to_len; to_len--) { + if (!isspace((unsigned char) to_r[to_len - 1])) { + break; + } + to_r[to_len - 1] = '\0'; + } + for (i = 0; to_r[i]; i++) { + if (iscntrl((unsigned char) to_r[i])) { + /* According to RFC 822, section 3.1.1 long headers may be +separated into + * parts using CRLF followed at least one linear-white-space +character ('\t' or ' '). + * To prevent these separators from being replaced with a space, +we use the + * SKIP_LONG_HEADER_SEP_MBSTRING to skip over them. + */ + SKIP_LONG_HEADER_SEP_MBSTRING(to_r, i); + to_r[i] = ' '; + } + } + } else { + to_r = to; + } } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Missing To: field"); err = 1; @@ -3553,12 +3597,15 @@ extra_cmd = Z_STRVAL_PP(argv[4]); } - if (!err && php_mail(to, subject, message, headers, extra_cmd TSRMLS_CC)) { + if (!err && php_mail(to_r, subject, message, headers, extra_cmd TSRMLS_CC)) { RETVAL_TRUE; } else { RETVAL_FALSE; } + if (to_r != to) { + efree(to_r); + } if (subject_buf) { efree((void *)subject_buf); }