Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions UPGRADING.INTERNALS
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions Zend/zend_API.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion ext/bz2/bz2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
10 changes: 4 additions & 6 deletions ext/dom/document.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion ext/gd/gd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions ext/hash/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion ext/openssl/openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion ext/phar/phar.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion main/fopen_wrappers.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down