Skip to content

ext/pdo_sqlite: PDO::sqliteCreateCollection return type strenghtening. #18799

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

devnexen
Copy link
Member

@devnexen devnexen commented Jun 7, 2025

Is supposed to be Pdo_Sqlite::createCollation alias but behavior differs in regard of return type checks.

Is supposed to be Pdo_Sqlite::createCollation but behavior differs in
regard of return type checks.
@devnexen devnexen force-pushed the pdo_sqlite_ext_create_collation branch from 7661ce5 to 4494e12 Compare June 7, 2025 15:54
@devnexen devnexen marked this pull request as ready for review June 7, 2025 16:48
@devnexen devnexen requested a review from SakiTakamachi as a code owner June 7, 2025 16:48
Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

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

MSTM, but this needs an UPGRADING entry as this is a BC technically

Comment on lines 390 to 394
if (Z_LVAL(retval) > 0) {
ret = 1;
} else if (Z_LVAL(retval) < 0) {
ret = -1;
}
Copy link
Member

Choose a reason for hiding this comment

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

Follow-up: Could we not use ZEND_NORMALIZE_BOOL here rather than doing it "manually"

Copy link
Member Author

Choose a reason for hiding this comment

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

not a bad idea !

@devnexen devnexen closed this in e3cfa4b Jun 8, 2025
@@ -385,14 +385,14 @@ static int php_sqlite_collation_callback(void *context, int string1_len, const v
zend_type_error("%s(): Return value of the collation callback must be of type int, %s returned",
ZSTR_VAL(func_name), zend_zval_value_name(&retval));
zend_string_release(func_name);
zval_ptr_dtor(&retval);
return FAILURE;
ret = FAILURE;
Copy link
Member

Choose a reason for hiding this comment

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

This change in this file is wrong, why did you change this?

Copy link
Member

Choose a reason for hiding this comment

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

In particular, you're accessing the zval as if it were a long below, but that's not the case. This means you're either interpreting garbage bytes or uninit memory.

zend_type_error("%s(): Return value of the collation callback must be of type int, %s returned",
ZSTR_VAL(func_name), zend_zval_value_name(&retval));
zend_string_release(func_name);
ret = FAILURE;
Copy link
Member

Choose a reason for hiding this comment

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

Similarly, this is also wrong

devnexen added a commit to devnexen/php-src that referenced this pull request Jun 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants