dom_object *intern;
dom_doc_propsptr doc_props;
char *file;
- long options = 0;
+ zend_long options = 0;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os|l", &id, dom_document_class_entry, &file, &file_len, &options) == FAILURE) {
- if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Op|l", &id, dom_document_class_entry, &file, &file_len, &options) == FAILURE) {
++ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Op|l", &id, dom_document_class_entry, &file, &file_len, &options) == FAILURE) {
return;
}
int is_valid;
char resolved_path[MAXPATHLEN + 1];
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Op|l", &id, dom_document_class_entry, &source, &source_len, &flags) == FAILURE) {
- if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|l", &id, dom_document_class_entry, &source, &source_len, &flags) == FAILURE) {
++ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os|l", &id, dom_document_class_entry, &source, &source_len, &flags) == FAILURE) {
return;
}
switch (type) {
case DOM_LOAD_FILE:
- valid_file = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN );
+ if (CHECK_NULL_PATH(source, source_len)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid Schema file source");
++ php_error_docref(NULL, E_WARNING, "Invalid Schema file source");
+ RETURN_FALSE;
+ }
+ valid_file = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC);
if (!valid_file) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid Schema file source");
+ php_error_docref(NULL, E_WARNING, "Invalid Schema file source");
RETURN_FALSE;
}
parser = xmlSchemaNewParserCtxt(valid_file);
int is_valid;
char resolved_path[MAXPATHLEN + 1];
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Op", &id, dom_document_class_entry, &source, &source_len) == FAILURE) {
- if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, dom_document_class_entry, &source, &source_len) == FAILURE) {
++ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &id, dom_document_class_entry, &source, &source_len) == FAILURE) {
return;
}
switch (type) {
case DOM_LOAD_FILE:
- valid_file = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN );
+ if (CHECK_NULL_PATH(source, source_len)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid RelaxNG file source");
++ php_error_docref(NULL, E_WARNING, "Invalid RelaxNG file source");
+ RETURN_FALSE;
+ }
+ valid_file = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC);
if (!valid_file) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid RelaxNG file source");
+ php_error_docref(NULL, E_WARNING, "Invalid RelaxNG file source");
RETURN_FALSE;
}
parser = xmlRelaxNGNewParserCtxt(valid_file);
id = getThis();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|l", &source, &source_len, &options) == FAILURE) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &source, &source_len, &options) == FAILURE) {
++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|l", &source, &source_len, &options) == FAILURE) {
return;
}
}
if (mode == DOM_LOAD_FILE) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid file source");
+ if (CHECK_NULL_PATH(source, source_len)) {
++ php_error_docref(NULL, E_WARNING, "Invalid file source");
+ RETURN_FALSE;
+ }
ctxt = htmlCreateFileParserCtxt(source, NULL);
} else {
- source_len = xmlStrlen(source);
+ source_len = xmlStrlen((xmlChar *) source);
ctxt = htmlCreateMemoryParserCtxt(source, source_len);
}
char *file;
const char *encoding;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &id, dom_document_class_entry, &file, &file_len) == FAILURE) {
- if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Op", &id, dom_document_class_entry, &file, &file_len) == FAILURE) {
++ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Op", &id, dom_document_class_entry, &file, &file_len) == FAILURE) {
return;
}
}
+ static int php_mail_detect_multiple_crlf(char *hdr) {
+ /* This function detects multiple/malformed multiple newlines. */
+ size_t len;
+
+ if (!hdr) {
+ return 0;
+ }
+
+ /* Should not have any newlines at the beginning. */
+ /* RFC 2822 2.2. Header Fields */
+ if (*hdr < 33 || *hdr > 126 || *hdr == ':') {
+ return 1;
+ }
+
+ while(*hdr) {
+ if (*hdr == '\r') {
+ if (*(hdr+1) == '\0' || *(hdr+1) == '\r' || (*(hdr+1) == '\n' && (*(hdr+2) == '\0' || *(hdr+2) == '\n' || *(hdr+2) == '\r'))) {
+ /* Malformed or multiple newlines. */
+ return 1;
+ } else {
+ hdr += 2;
+ }
+ } else if (*hdr == '\n') {
+ if (*(hdr+1) == '\0' || *(hdr+1) == '\r' || *(hdr+1) == '\n') {
+ /* Malformed or multiple newlines. */
+ return 1;
+ } else {
+ hdr += 2;
+ }
+ } else {
+ hdr++;
+ }
+ }
+
+ return 0;
+ }
+
+
/* {{{ php_mail
*/
-PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char *extra_cmd TSRMLS_DC)
+PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char *extra_cmd)
{
#if (defined PHP_WIN32 || defined NETWARE)
int tsm_err;
efree(tmp);
}
+
if (PG(mail_x_header)) {
- const char *tmp = zend_get_executed_filename(TSRMLS_C);
- char *f;
- size_t f_len;
+ const char *tmp = zend_get_executed_filename();
+ zend_string *f;
- php_basename(tmp, strlen(tmp), NULL, 0,&f, &f_len TSRMLS_CC);
+ f = php_basename(tmp, strlen(tmp), NULL, 0);
if (headers != NULL) {
- spprintf(&hdr, 0, "X-PHP-Originating-Script: %ld:%s\n%s", php_getuid(TSRMLS_C), f, headers);
+ spprintf(&hdr, 0, "X-PHP-Originating-Script: " ZEND_LONG_FMT ":%s\n%s", php_getuid(), f->val, headers);
} else {
- spprintf(&hdr, 0, "X-PHP-Originating-Script: %ld:%s", php_getuid(TSRMLS_C), f);
+ spprintf(&hdr, 0, "X-PHP-Originating-Script: " ZEND_LONG_FMT ":%s", php_getuid(), f->val);
}
- efree(f);
+ zend_string_release(f);
}
+ if (hdr && php_mail_detect_multiple_crlf(hdr)) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Multiple or malformed newlines found in additional_header");
+ MAIL_RET(0);
+ }
+
if (!sendmail_path) {
#if (defined PHP_WIN32 || defined NETWARE)
/* handle old style win smtp sending */