Skip to content

Refuse sqlite3_rekey_v2 while a transaction is open - #627

Open
LucaCappelletti94 wants to merge 1 commit into
sqlcipher:betafrom
LucaCappelletti94:upstream/rekey-in-transaction
Open

LucaCappelletti94 wants to merge 1 commit into
sqlcipher:betafrom
LucaCappelletti94:upstream/rekey-in-transaction

Conversation

@LucaCappelletti94

Copy link
Copy Markdown

On 5.0.0-beta, sqlite3_rekey_v2 commits its btree transaction even when the connection already holds one, so it ends a transaction it never owned. Inside BEGIN or SAVEPOINT, a later ROLLBACK then restores nothing. From a callback of a running INSERT, it commits the partial writes, and an INSERT that then fails stays half applied. Alongside a SELECT still stepping, it drops the read lock under the open cursor, which trips an assertion in SQLITE_DEBUG builds.

As PRAGMA cipher_migrate already does, sqlite3_rekey_v2 now returns SQLITE_MISUSE when autocommit is off or the target btree holds any transaction. The check runs before anything is touched and returns directly, since the cleanup path would roll back the caller's transaction.

The tests cover BEGIN, SAVEPOINT, an attached schema, a running INSERT and a running SELECT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant