Projects
home:rottame:vhosts-ng:php80
php8
php8-CVE-2026-6735.patch
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File php8-CVE-2026-6735.patch of Package php8
Index: php-8.0.30/ext/json/json.c =================================================================== --- php-8.0.30.orig/ext/json/json.c +++ php-8.0.30/ext/json/json.c @@ -145,6 +145,21 @@ static PHP_MINFO_FUNCTION(json) } /* }}} */ +PHP_JSON_API zend_string *php_json_encode_string(const char *s, size_t len, int options) +{ + smart_str buf = {0}; + php_json_encoder encoder; + + php_json_encode_init(&encoder); + + if (php_json_escape_string(&buf, s, len, options, &encoder) == FAILURE) { + smart_str_free(&buf); + return NULL; + } + + return smart_str_extract(&buf); +} + PHP_JSON_API int php_json_encode_ex(smart_str *buf, zval *val, int options, zend_long depth) /* {{{ */ { php_json_encoder encoder; Index: php-8.0.30/ext/json/json_encoder.c =================================================================== --- php-8.0.30.orig/ext/json/json_encoder.c +++ php-8.0.30/ext/json/json_encoder.c @@ -30,7 +30,7 @@ static const char digits[] = "0123456789abcdef"; -static int php_json_escape_string( +int php_json_escape_string( smart_str *buf, const char *s, size_t len, int options, php_json_encoder *encoder); @@ -252,7 +252,7 @@ static int php_json_encode_array(smart_s } /* }}} */ -static int php_json_escape_string( +int php_json_escape_string( smart_str *buf, const char *s, size_t len, int options, php_json_encoder *encoder) /* {{{ */ { Index: php-8.0.30/ext/json/php_json_encoder.h =================================================================== --- php-8.0.30.orig/ext/json/php_json_encoder.h +++ php-8.0.30/ext/json/php_json_encoder.h @@ -35,4 +35,6 @@ static inline void php_json_encode_init( int php_json_encode_zval(smart_str *buf, zval *val, int options, php_json_encoder *encoder); +int php_json_escape_string(smart_str *buf, const char *s, size_t len, int options, php_json_encoder *encoder); + #endif /* PHP_JSON_ENCODER_H */ Index: php-8.0.30/ext/json/php_json.h =================================================================== --- php-8.0.30.orig/ext/json/php_json.h +++ php-8.0.30/ext/json/php_json.h @@ -96,6 +96,8 @@ PHP_JSON_API ZEND_EXTERN_MODULE_GLOBALS( ZEND_TSRMLS_CACHE_EXTERN() #endif +PHP_JSON_API zend_string *php_json_encode_string(const char *s, size_t len, int options); + PHP_JSON_API int php_json_encode_ex(smart_str *buf, zval *val, int options, zend_long depth); PHP_JSON_API int php_json_encode(smart_str *buf, zval *val, int options); PHP_JSON_API int php_json_decode_ex(zval *return_value, const char *str, size_t str_len, zend_long options, zend_long depth); Index: php-8.0.30/sapi/fpm/fpm/fpm_status.c =================================================================== --- php-8.0.30.orig/sapi/fpm/fpm/fpm_status.c +++ php-8.0.30/sapi/fpm/fpm/fpm_status.c @@ -13,7 +13,8 @@ #include "fpm_atomic.h" #include "fpm_conf.h" #include "fpm_php.h" -#include <ext/standard/html.h> +#include "ext/standard/html.h" +#include "ext/json/php_json.h" static char *fpm_status_uri = NULL; static char *fpm_status_ping_uri = NULL; @@ -140,7 +141,7 @@ int fpm_status_handle_request(void) /* { struct fpm_scoreboard_proc_s *proc; char *buffer, *time_format, time_buffer[64]; time_t now_epoch; - int full, encode; + int full, encode, encode_json; char *short_syntax, *short_post; char *full_pre, *full_syntax, *full_post, *full_separator; zend_string *_GET_str; @@ -176,6 +177,7 @@ int fpm_status_handle_request(void) /* { short_syntax = short_post = NULL; full_separator = full_pre = full_syntax = full_post = NULL; encode = 0; + encode_json = 0; scoreboard_p = fpm_scoreboard_get(); if (scoreboard_p) { @@ -334,6 +336,7 @@ int fpm_status_handle_request(void) /* { } else if (fpm_php_get_string_from_table(_GET_str, "json")) { sapi_add_header_ex(ZEND_STRL("Content-Type: application/json"), 1, 1); time_format = "%s"; + encode_json = 1; short_syntax = "{" @@ -448,8 +451,8 @@ int fpm_status_handle_request(void) /* { if (full_syntax) { unsigned int i; int first; - zend_string *tmp_query_string; - char *query_string; + zend_string *tmp_query_string, *tmp_request_uri_string; + char *query_string, *request_uri_string; struct timeval duration, now; float cpu; @@ -474,14 +477,50 @@ int fpm_status_handle_request(void) /* { } } + request_uri_string = NULL; + tmp_request_uri_string = NULL; + if (proc->request_uri[0] != '\0') { + if (encode) { + tmp_request_uri_string = php_escape_html_entities_ex( + (const unsigned char *) proc->request_uri, + strlen(proc->request_uri), 1, ENT_DISALLOWED | ENT_HTML_DOC_XML1 | ENT_COMPAT, + NULL, /* double_encode */ 1, /* quiet */ 0); + request_uri_string = ZSTR_VAL(tmp_request_uri_string); + } else if (encode_json) { + tmp_request_uri_string = php_json_encode_string(proc->request_uri, + strlen(proc->request_uri), PHP_JSON_INVALID_UTF8_IGNORE); + request_uri_string = ZSTR_VAL(tmp_request_uri_string); + /* remove quotes around the string */ + if (ZSTR_LEN(tmp_request_uri_string) >= 2) { + request_uri_string[ZSTR_LEN(tmp_request_uri_string) - 1] = '\0'; + ++request_uri_string; + } + } else { + request_uri_string = proc->request_uri; + } + } + query_string = NULL; tmp_query_string = NULL; if (proc->query_string[0] != '\0') { - if (!encode) { - query_string = proc->query_string; + if (encode) { + tmp_query_string = php_escape_html_entities_ex( + (const unsigned char *) proc->query_string, + strlen(proc->query_string), 1, ENT_DISALLOWED | ENT_HTML_DOC_XML1 | ENT_COMPAT, + NULL, /* double_encode */ 1, /* quiet */ 0); + } else if (encode_json) { + tmp_query_string = php_json_encode_string(proc->query_string, + strlen(proc->query_string), PHP_JSON_INVALID_UTF8_IGNORE); } else { - tmp_query_string = php_escape_html_entities_ex((const unsigned char *) proc->query_string, strlen(proc->query_string), 1, ENT_HTML_IGNORE_ERRORS & ENT_COMPAT, NULL, /* double_encode */ 1, /* quiet */ 0); + query_string = proc->query_string; + } + if (tmp_query_string) { query_string = ZSTR_VAL(tmp_query_string); + /* remove quotes around the string */ + if (encode_json && ZSTR_LEN(tmp_query_string) >= 2) { + query_string[ZSTR_LEN(tmp_query_string) - 1] = '\0'; + ++query_string; + } } } @@ -506,7 +545,7 @@ int fpm_status_handle_request(void) /* { proc->requests, duration.tv_sec * 1000000UL + duration.tv_usec, proc->request_method[0] != '\0' ? proc->request_method : "-", - proc->request_uri[0] != '\0' ? proc->request_uri : "-", + request_uri_string ? request_uri_string : "-", query_string ? "?" : "", query_string ? query_string : "", proc->content_length, @@ -516,6 +555,10 @@ int fpm_status_handle_request(void) /* { proc->request_stage == FPM_REQUEST_ACCEPTING ? proc->memory : 0); PUTS(buffer); efree(buffer); + + if (tmp_request_uri_string) { + zend_string_free(tmp_request_uri_string); + } if (tmp_query_string) { zend_string_free(tmp_query_string);
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.