php / php/php-src

Inconsistent/missing checks for sqlite3 APIs

Open
#22,051 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Extension: sqlite3 Status: Needs Triage
Dominant language
C
Stars
40.4k
Forks
8.1k
Avg merge
2d 13h
Merged PRs (30d)
96

Description

Description

Several calls to sqlite3_reset and sqlite3_finalize are unchecked.

Some calls to sqlite3_reset are checked and then the value is returned to the user:

https://github.com/php/php-src/blob/cde32beadeee04c16d8607266ea7586078fbc9df/ext/sqlite3/sqlite3.c#L1414-L1417

https://github.com/php/php-src/blob/cde32beadeee04c16d8607266ea7586078fbc9df/ext/sqlite3/sqlite3.c#L2101-L2103

Note however an inconsistency between these two: one of them throw/warns and the other one doesn't. This likely needs to be made consistent.

It's probably best if the calls to sqlite3_reset and sqlite3_finalize are checked consistently everywhere.

Note: found by a static-dynamic hybrid analyzer I'm developing.

PHP Version
Checked on master branch
Operating System

N/A

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in ext/sqlite3/sqlite3.c by auditing the sqlite3_reset and sqlite3_finalize calls, including the locations at lines 1414-1417 and 2101-2103. Compare their checking and throw/warn behavior. Done means the relevant calls are checked consistently and the differing behavior is reconciled.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, sqlite
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.