Skip to content
Open
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
2 changes: 1 addition & 1 deletion ext/odbc/php_odbc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ PHP_FUNCTION(odbc_execute)

if (ZSTR_LEN(tmpstr) > 2 &&
ZSTR_VAL(tmpstr)[0] == '\'' &&
ZSTR_VAL(tmpstr)[ZSTR_LEN(tmpstr) - 1] == '\'') {
zend_string_ends_with_literal(tmpstr, "'")) {

if (UNEXPECTED(zend_str_has_nul_byte(tmpstr))) {
odbc_release_params(result, params);
Expand Down
4 changes: 2 additions & 2 deletions ext/opcache/ZendAccelerator.c
Original file line number Diff line number Diff line change
Expand Up @@ -1519,8 +1519,8 @@ static void zend_accel_add_key(zend_string *key, zend_accel_hash_entry *bucket)

static zend_always_inline bool is_phar_file(const zend_string *filename)
{
return filename && ZSTR_LEN(filename) >= sizeof(".phar") &&
!memcmp(ZSTR_VAL(filename) + ZSTR_LEN(filename) - (sizeof(".phar")-1), ".phar", sizeof(".phar")-1) &&
return filename &&
zend_string_ends_with_literal(filename, ".phar") &&
!strstr(ZSTR_VAL(filename), "://");
}

Expand Down
2 changes: 1 addition & 1 deletion ext/pgsql/pgsql.c
Original file line number Diff line number Diff line change
Expand Up @@ -3427,7 +3427,7 @@ static zend_result pgsql_copy_from_query(PGconn *pgsql, PGresult *pgsql_result,
}

int result;
if (ZSTR_LEN(tmp) > 0 && ZSTR_VAL(tmp)[ZSTR_LEN(tmp) - 1] != '\n') {
if (ZSTR_LEN(tmp) > 0 && !zend_string_ends_with_literal(tmp, "\n")) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

@LamentXU123 LamentXU123 Aug 12, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has a behavior impact when you delete the ZSTR_LEN(tmp) > 0 check.

You see, when tmp is an empty string, here !zend_string_ends_with_literal(tmp, "\n") is true, and we clearly don't want to add \n in empty strings.

char *zquery = zend_cstr_append_char(
ZSTR_VAL(tmp), ZSTR_LEN(tmp), '\n');
result = PQputCopyData(pgsql, zquery, ZSTR_LEN(tmp) + 1);
Expand Down
2 changes: 1 addition & 1 deletion ext/phar/phar_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -4251,7 +4251,7 @@ ZEND_ATTRIBUTE_NONNULL_ARGS(1, 3, 5) static int extract_helper(const phar_archiv
if (FAILURE == phar_extract_file(overwrite, entry, path_to, error)) return -1;
extracted++;
} ZEND_HASH_FOREACH_END();
} else if (ZSTR_LEN(search) > 0 && '/' == ZSTR_VAL(search)[ZSTR_LEN(search) - 1]) {
} else if (zend_string_ends_with_literal(search, "/")) {
/* ends in "/" -- extract all entries having that prefix */
ZEND_HASH_MAP_FOREACH_PTR(&archive->manifest, entry) {
if (!zend_string_starts_with(entry->filename, search)) continue;
Expand Down
2 changes: 1 addition & 1 deletion ext/session/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ static PHP_INI_MH(OnUpdateRfc1867Freq)
return FAILURE;
}

if (ZSTR_LEN(new_value) > 0 && ZSTR_VAL(new_value)[ZSTR_LEN(new_value) - 1] == '%') {
if (zend_string_ends_with_literal(new_value, "%")) {
if (new_freq > 100) {
php_error_docref(NULL, E_WARNING, "session.upload_progress.freq must be less than or equal to 100%%");
return FAILURE;
Expand Down
8 changes: 2 additions & 6 deletions ext/soap/php_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,9 @@ static php_stream* http_connect(zval* this_ptr, php_uri *uri, bool use_ssl, php_
static bool in_domain(const zend_string *host, const zend_string *domain)
{
if (ZSTR_VAL(domain)[0] == '.') {
if (ZSTR_LEN(host) > ZSTR_LEN(domain)) {
return zend_string_equals_cstr(domain, ZSTR_VAL(host) + ZSTR_LEN(host) - ZSTR_LEN(domain), ZSTR_LEN(domain));
} else {
return false;
}
return ZSTR_LEN(host) > ZSTR_LEN(domain) && zend_string_ends_with(host, domain);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

@LamentXU123 LamentXU123 Aug 12, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this shouldn't be changed. This missed the ZSTR_LEN(host) == ZSTR_LEN(domain) case.

} else {
return zend_string_equals(host,domain);
return zend_string_equals(host, domain);
}
}

Expand Down
Loading