-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
} | ||
if (Z_LVAL(retval) > 0) { | ||
ret = 1; | ||
} else if (Z_LVAL(retval) < 0) { | ||
ret = -1; | ||
} | ||
Comment on lines
390
to
394
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Follow-up: Could we not use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not a bad idea ! |
||
zval_ptr_dtor(&retval); | ||
} | ||
|
||
return ret; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -483,9 +483,16 @@ static int php_sqlite3_collation_callback(void *context, int string1_len, const | |
|
||
zend_call_known_fcc(&collation->callback, &retval, /* argc */ 2, zargs, /* named_params */ NULL); | ||
|
||
zval_ptr_dtor(&zargs[0]); | ||
zval_ptr_dtor(&zargs[1]); | ||
|
||
if (!Z_ISUNDEF(retval)) { | ||
if (Z_TYPE(retval) != IS_LONG) { | ||
convert_to_long(&retval); | ||
zend_string *func_name = get_active_function_or_method_name(); | ||
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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly, this is also wrong |
||
} | ||
if (Z_LVAL(retval) > 0) { | ||
ret = 1; | ||
|
@@ -495,9 +502,6 @@ static int php_sqlite3_collation_callback(void *context, int string1_len, const | |
zval_ptr_dtor(&retval); | ||
} | ||
|
||
zval_ptr_dtor(&zargs[0]); | ||
zval_ptr_dtor(&zargs[1]); | ||
|
||
return ret; | ||
} | ||
|
||
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.