Skip to content

sqlite: fix error checks for column retrieval#22045

Open
ndossche wants to merge 1 commit into
php:PHP-8.4from
ndossche:clesss-38
Open

sqlite: fix error checks for column retrieval#22045
ndossche wants to merge 1 commit into
php:PHP-8.4from
ndossche:clesss-38

Conversation

@ndossche
Copy link
Copy Markdown
Member

These can return NULL on OOM.
And for blobs, it can return NULL for empty blobs (so no failure, just an edge case). Passing NULL to memcpy is UB, so we have to check for a NULL pointer there to avoid UB.

Found by a static-dynamic analyser I'm developing.

These can return NULL on OOM.
And for blobs, it can return NULL for empty blobs (so *no* failure,
just an edge case). Passing NULL to memcpy is UB, so we have to
check for a NULL pointer there to avoid UB.
@devnexen
Copy link
Copy Markdown
Member

that falls into "defensive programming" IMHO. How likely ? not sure it belongs to PHP-8.4 ; if Saki says otherwise I won't object.

@ndossche
Copy link
Copy Markdown
Member Author

that falls into "defensive programming" IMHO. How likely ?

At least the empty blob case should be easily hittable in production, which can cause UB in the memcpy path when the string initializes. The OOM checks are defensive.

@devnexen
Copy link
Copy Markdown
Member

ok that s a valid point. for sure the changes are correct to me :)

Copy link
Copy Markdown
Member

@devnexen devnexen left a comment

Choose a reason for hiding this comment

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

I was a bit on the fence with some subtle changes here and there but I do not object for 8.4

@ndossche
Copy link
Copy Markdown
Member Author

I can also split this PR into 2: one for the empty blob; and one for the OOM checks.
We can wait for Saki to decide.

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