Skip to content

ext/pdo: Refactor validation of fetch mode in PDO statement #17699

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

Merged
merged 4 commits into from
Feb 9, 2025

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Feb 4, 2025

No description provided.

@Girgias Girgias force-pushed the pdo-stm-set-fetch-mode branch from 249ece9 to 6440b24 Compare February 4, 2025 20:05
@Girgias Girgias marked this pull request as ready for review February 4, 2025 20:59
@Girgias Girgias requested a review from nielsdos February 4, 2025 21:00

if (mode < 0 || mode >= PDO_FETCH__MAX) {
/* Mode must be a positive */
if (mode_and_flags < 0 || mode_and_flags >= PDO_FIRST_INVALID_FLAG) {
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this change is right. What if mode is equal to 15? This number doesn't correspond to a real mode but it will not trigger the mode_and_flags >= PDO_FIRST_INVALID_FLAG condition.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, I'll add a test for this.

Copy link
Member

Choose a reason for hiding this comment

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

Okay, just this test then and then it's good to go.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually this is properly guarded by the switch (mode) { below, but the test just ensure this continues to be the case.

Copy link
Member

Choose a reason for hiding this comment

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

Well, now we know for sure!

Girgias and others added 3 commits February 8, 2025 22:24
This affects the value of the fetch mode flags
Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
@Girgias Girgias force-pushed the pdo-stm-set-fetch-mode branch from 492357e to 0cf1e6b Compare February 8, 2025 22:44
Copy link
Member

@nielsdos nielsdos left a comment

Choose a reason for hiding this comment

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

The change of value should probably get an upgrading entry. I hope no one is (implicitly) relying on those

@Girgias Girgias merged commit 4e55889 into php:master Feb 9, 2025
1 check passed
@Girgias Girgias deleted the pdo-stm-set-fetch-mode branch February 9, 2025 00:35
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.

2 participants