diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index eab5ad233be3c..fe2781e025687 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -26,6 +26,9 @@ PHP 8.6 INTERNALS UPGRADE NOTES call the variant without the leading underscore instead. Affected: _zval_get_long, _zval_get_double, _zval_get_string, _zval_get_long_func, _zval_get_double_func, _zval_get_string_func + . CHECK_ZVAL_NULL_PATH() and CHECK_NULL_PATH() have been removed, use + zend_str_has_nul_byte(Z_STR_P(...)) and zend_char_has_nul_byte() + respectively. ======================== 2. Build system changes diff --git a/Zend/zend_API.h b/Zend/zend_API.h index f3a56eff95079..4e2954c0a65c8 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -951,10 +951,6 @@ static zend_always_inline bool zend_char_has_nul_byte(const char *s, size_t know return known_length != strlen(s); } -/* Compatibility with PHP 8.1 and below */ -#define CHECK_ZVAL_NULL_PATH(p) zend_str_has_nul_byte(Z_STR_P(p)) -#define CHECK_NULL_PATH(p, l) zend_char_has_nul_byte(p, l) - #define ZVAL_STRINGL(z, s, l) do { \ ZVAL_NEW_STR(z, zend_string_init(s, l, 0)); \ } while (0) diff --git a/ext/bz2/bz2.c b/ext/bz2/bz2.c index aff9d5c11b9ed..e7491f12cf315 100644 --- a/ext/bz2/bz2.c +++ b/ext/bz2/bz2.c @@ -352,7 +352,7 @@ PHP_FUNCTION(bzopen) RETURN_THROWS(); } - if (CHECK_ZVAL_NULL_PATH(file)) { + if (zend_str_has_nul_byte(Z_STR_P(file))) { zend_argument_type_error(1, "must not contain null bytes"); RETURN_THROWS(); } diff --git a/ext/dom/document.c b/ext/dom/document.c index 4d366db08f0eb..4a10f4dd19b6f 100644 --- a/ext/dom/document.c +++ b/ext/dom/document.c @@ -1380,10 +1380,8 @@ xmlDocPtr dom_document_parser(zval *id, dom_load_mode mode, const char *source, substitute_ent = doc_props->substituteentities; recover = doc_props->recover || (options & XML_PARSE_RECOVER) == XML_PARSE_RECOVER; - xmlInitParser(); - if (mode == DOM_LOAD_FILE) { - if (CHECK_NULL_PATH(source, source_len)) { + if (zend_char_has_nul_byte(source, source_len)) { zend_argument_value_error(1, "must not contain any null bytes"); return NULL; } @@ -1866,7 +1864,7 @@ static void dom_document_schema_validate(INTERNAL_FUNCTION_PARAMETERS, int type) switch (type) { case DOM_LOAD_FILE: - if (CHECK_NULL_PATH(source, source_len)) { + if (zend_char_has_nul_byte(source, source_len)) { PHP_LIBXML_RESTORE_GLOBALS(new_parser_ctxt); zend_argument_value_error(1, "must not contain any null bytes"); RETURN_THROWS(); @@ -1973,7 +1971,7 @@ static void dom_document_relaxNG_validate(INTERNAL_FUNCTION_PARAMETERS, int type switch (type) { case DOM_LOAD_FILE: - if (CHECK_NULL_PATH(source, source_len)) { + if (zend_char_has_nul_byte(source, source_len)) { zend_argument_value_error(1, "must not contain any null bytes"); RETURN_THROWS(); } @@ -2066,7 +2064,7 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */ } if (mode == DOM_LOAD_FILE) { - if (CHECK_NULL_PATH(source, source_len)) { + if (zend_char_has_nul_byte(source, source_len)) { zend_argument_value_error(1, "must not contain any null bytes"); RETURN_THROWS(); } diff --git a/ext/gd/gd.c b/ext/gd/gd.c index df741ef255d4a..e946ec73d7dbb 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -4378,7 +4378,7 @@ static gdIOCtx *create_output_context(zval *to_zval, uint32_t arg_num) { } close_stream = 0; } else if (Z_TYPE_P(to_zval) == IS_STRING) { - if (CHECK_ZVAL_NULL_PATH(to_zval)) { + if (zend_str_has_nul_byte(Z_STR_P(to_zval))) { zend_argument_type_error(arg_num, "must not contain null bytes"); return NULL; } diff --git a/ext/hash/hash.c b/ext/hash/hash.c index 98a52536a683a..d255711efbed9 100644 --- a/ext/hash/hash.c +++ b/ext/hash/hash.c @@ -365,7 +365,7 @@ static void php_hash_do_hash( RETURN_THROWS(); } if (isfilename) { - if (CHECK_NULL_PATH(data, data_len)) { + if (zend_char_has_nul_byte(data, data_len)) { zend_argument_value_error(1, "must not contain any null bytes"); RETURN_THROWS(); } @@ -508,7 +508,7 @@ static void php_hash_do_hash_hmac( } if (isfilename) { - if (CHECK_NULL_PATH(data, data_len)) { + if (zend_char_has_nul_byte(data, data_len)) { zend_argument_value_error(2, "must not contain any null bytes"); RETURN_THROWS(); } diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index 736bdf315e3e9..2c09b89e31200 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -303,7 +303,7 @@ bool php_openssl_check_path_ex( fs_file_path_len = file_path_len; } - if (CHECK_NULL_PATH(fs_file_path, fs_file_path_len)) { + if (zend_char_has_nul_byte(fs_file_path, fs_file_path_len)) { error_msg = "must not contain any null bytes"; error_type = E_ERROR; } else if (expand_filepath(fs_file_path, real_path) == NULL) { diff --git a/ext/phar/phar.c b/ext/phar/phar.c index 6d408708fc246..39ef82e901441 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -2251,7 +2251,7 @@ zend_result phar_split_fname(const char *filename, size_t filename_len, char **a #endif size_t ext_len; - if (CHECK_NULL_PATH(filename, filename_len)) { + if (zend_char_has_nul_byte(filename, filename_len)) { return FAILURE; } diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c index fc0dbb9a984ea..63564cc73bdfc 100644 --- a/main/fopen_wrappers.c +++ b/main/fopen_wrappers.c @@ -506,7 +506,7 @@ PHPAPI zend_string *php_resolve_path(const char *filename, size_t filename_lengt php_stream_wrapper *wrapper; zend_string *exec_filename; - if (!filename || CHECK_NULL_PATH(filename, filename_length)) { + if (!filename || zend_char_has_nul_byte(filename, filename_length)) { return NULL; }