mirror of
https://github.com/php/php-src.git
synced 2025-08-18 23:18:56 +02:00
fix possible XSS in error messages
This commit is contained in:
parent
1f54605723
commit
4535ff1756
1 changed files with 16 additions and 0 deletions
16
main/main.c
16
main/main.c
|
@ -439,6 +439,14 @@ PHPAPI void php_verror(const char *docref, const char *params, int type, const c
|
|||
|
||||
buffer_len = vspprintf(&buffer, 0, format, args);
|
||||
if (buffer) {
|
||||
if (PG(html_errors)) {
|
||||
int len;
|
||||
char *replace = php_escape_html_entities(buffer, buffer_len, &len, 0, ENT_COMPAT, NULL TSRMLS_CC);
|
||||
efree(buffer);
|
||||
buffer = replace;
|
||||
buffer_len = len;
|
||||
}
|
||||
|
||||
if (docref && docref[0] == '#') {
|
||||
docref_target = strchr(docref, '#');
|
||||
docref = NULL;
|
||||
|
@ -571,6 +579,14 @@ static void php_error_cb(int type, const char *error_filename, const uint error_
|
|||
TSRMLS_FETCH();
|
||||
|
||||
buffer_len = vspprintf(&buffer, PG(log_errors_max_len), format, args);
|
||||
if (PG(html_errors)) {
|
||||
int len;
|
||||
char *replace = php_escape_html_entities(buffer, buffer_len, &len, 0, ENT_COMPAT, NULL TSRMLS_CC);
|
||||
efree(buffer);
|
||||
buffer = replace;
|
||||
buffer_len = len;
|
||||
}
|
||||
|
||||
if (PG(ignore_repeated_errors)) {
|
||||
if (strncmp(last_error.buf, buffer, sizeof(last_error.buf))
|
||||
|| (!PG(ignore_repeated_source)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue