Skip to content
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

Assertion failure when compiled with SQLITE_DEBUG #55

Closed
m4heshd opened this issue Nov 18, 2021 · 6 comments
Closed

Assertion failure when compiled with SQLITE_DEBUG #55

m4heshd opened this issue Nov 18, 2021 · 6 comments

Comments

@m4heshd
Copy link
Contributor

m4heshd commented Nov 18, 2021

What I wanted to know is if this is the intended behavior for Sqlitemc.

I'm compiling Sqlitemc with SQLITE_DEBUG set just for the tests. The assertion failure happens if you try to decrypt the DB with an incorrect passphrase (Sqleet) using PRAGMA key which exactly is the scenario I'm trying to test with Mocha. But since JS doesn't catch C++ runtime errors, the whole test process fails because of it.

// Line 53647 in amalgamated sqlite3.c

case PAGER_READER:
  assert( pPager->errCode==SQLITE_OK ); //⬅ this one
  assert( p->eLock!=UNKNOWN_LOCK );
  assert( p->eLock>=SHARED_LOCK );
  break;

Was this assert() supposed fail on the above mentioned scenario? 🤔

@utelle
Copy link
Owner

utelle commented Nov 18, 2021

What I wanted to know is if this is the intended behavior for Sqlitemc.

I'm compiling Sqlitemc with SQLITE_DEBUG set just for the tests. The assertion failure happens if you try to decrypt the DB with an incorrect passphrase (Sqleet) using PRAGMA key which exactly is the scenario I'm trying to test with Mocha. But since JS doesn't catch C++ runtime errors, the whole test process fails because of it.

Was this assert() supposed fail on the above mentioned scenario? 🤔

When SQLite3MC fails to decrypt a database page, the error code of the SQLite pager is set to a value other than SQLITE_OK. However, most likely the error state of the SQLite pager should also be activated. Currently, the latter is not the case.

I will look into the error handling and I will try to adjust it to avoid the problem you experienced.

@m4heshd
Copy link
Contributor Author

m4heshd commented Nov 18, 2021

I will look into the error handling and I will try to adjust it to avoid the problem you experienced.

Perfect. And thank you for the fast response, as always.

utelle added a commit that referenced this issue Nov 18, 2021
- Set pager error state on reporting decrypt error condition to avoid assertion when SQLITE_DEBUG is defined (issue #55)
- Check definition of symbol `__QNX__` to support compilation for QNX (issue #54)
- Apply minor adjustments to ChaCha20 implementation (taken from upstream resilar/sqleet)
@utelle
Copy link
Owner

utelle commented Nov 18, 2021

Commit 11a7462 should fix the issue.

A new release will be made shortly after the release of SQLite version 3.37.0 (expected in early December 2021).

@m4heshd
Copy link
Contributor Author

m4heshd commented Nov 18, 2021

Amazing. Such good news. I almost didn't report this since it's very niche but now I'm glad I brought this to your attention. Gracias. 👏🏼

@utelle
Copy link
Owner

utelle commented Nov 28, 2021

The latest release (version 1.3.5) now includes this fix.

@utelle utelle closed this as completed Nov 28, 2021
m4heshd added a commit to m4heshd/better-sqlite3-multiple-ciphers that referenced this issue Nov 29, 2021
@m4heshd
Copy link
Contributor Author

m4heshd commented Nov 29, 2021

The latest release (version 1.3.5) now includes this fix.

Nice. All tests are passing now.

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

No branches or pull requests

2 participants