diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index eab5ad233be3..fe2781e02568 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 f3a56eff9507..4e2954c0a65c 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 aff9d5c11b9e..e7491f12cf31 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 2152d98622a9..4a10f4dd19b6 100644 --- a/ext/dom/document.c +++ b/ext/dom/document.c @@ -1381,7 +1381,7 @@ xmlDocPtr dom_document_parser(zval *id, dom_load_mode mode, const char *source, recover = doc_props->recover || (options & XML_PARSE_RECOVER) == XML_PARSE_RECOVER; 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; } @@ -1864,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(); @@ -1971,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(); } @@ -2064,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 df741ef255d4..e946ec73d7db 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 98a52536a683..d255711efbed 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 736bdf315e3e..2c09b89e3120 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 6d408708fc24..50c7b778cc40 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -1596,7 +1596,7 @@ zend_result phar_open_from_filename(char *fname, size_t fname_len, char *alias, } /* }}}*/ -static inline char *phar_strnstr(const char *buf, int buf_len, const char *search, int search_len) /* {{{ */ +static inline char *phar_strnstr(const char *buf, size_t buf_len, const char *search, size_t search_len) /* {{{ */ { const char *c; ptrdiff_t so_far = 0; @@ -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/ext/phar/stream.c b/ext/phar/stream.c index 2317c07d6411..285b73cf88fd 100644 --- a/ext/phar/stream.c +++ b/ext/phar/stream.c @@ -665,7 +665,7 @@ static int phar_wrapper_unlink(php_stream_wrapper *wrapper, const char *url, int { php_url *resource; char *internal_file, *error; - int internal_file_len; + size_t internal_file_len; phar_entry_data *idata; phar_archive_data *pphar; diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c index fc0dbb9a984e..63564cc73bdf 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; }