Commit Graph

21 Commits

Author SHA1 Message Date
Hennadii Stepanov 090b8385af
Set bilingual error completely 2020-11-05 11:28:37 +02:00
Sebastian Falbesoner 56a461f727 wallet: fix buffer over-read in SQLite file magic check
If there is no terminating zero within the 16 magic bytes, the buffer would be
over-read in the std::string constructor. Fixed by using the "from buffer"
variant of the ctor (that also takes a size) rather than the "from c-string"
variant.
2020-10-22 03:39:55 +02:00
Andrew Chow f023b7cac0 wallet: Enforce sqlite serialized threading mode 2020-10-14 11:28:18 -04:00
Andrew Chow 6173269866 Set and check the sqlite user version 2020-10-14 11:28:18 -04:00
Andrew Chow 9d3d2d263c Use network magic as sqlite wallet application ID 2020-10-14 11:28:18 -04:00
Andrew Chow ac38a87225 Determine wallet file type based on file magic 2020-10-14 11:28:18 -04:00
Andrew Chow 6045f77003 Implement SQLiteDatabase::MakeBatch 2020-10-14 11:28:18 -04:00
Andrew Chow 727e6b2a4e Implement SQLiteDatabase::Verify 2020-10-14 11:28:18 -04:00
Andrew Chow b4df8fdb19 Implement SQLiteDatabase::Rewrite
Rewrite uses the VACUUM command which does exactly what we want. A
specific advertised use case is to compact a database and ensure that
any deleted data is actually deleted.
2020-10-14 11:28:18 -04:00
Andrew Chow 010e365906 Implement SQLiteDatabase::TxnBegin, TxnCommit, and TxnAbort 2020-10-14 11:28:18 -04:00
Andrew Chow ac5c1617e7 Implement SQLiteDatabase::Backup 2020-10-14 11:28:18 -04:00
Andrew Chow f6f9cd6a64 Implement SQLiteBatch::StartCursor, ReadAtCursor, and CloseCursor 2020-10-14 11:28:18 -04:00
Andrew Chow bf90e033f4 Implement SQLiteBatch::ReadKey, WriteKey, EraseKey, and HasKey 2020-10-14 11:28:18 -04:00
Andrew Chow 7aa45620e2 Add SetupSQLStatements 2020-10-14 11:28:18 -04:00
Andrew Chow 6636a2608a Implement SQLiteBatch::Close 2020-10-14 11:28:18 -04:00
Andrew Chow 93825352a3 Implement SQLiteDatabase::Close 2020-10-14 11:28:18 -04:00
Andrew Chow a0de83372b Implement SQLiteDatabase::Open 2020-10-14 11:28:18 -04:00
Andrew Chow 3bfa0fe125 Initialize and Shutdown sqlite3 globals
sqlite3 recommends that sqlite3_initialize be called when the
application starts, and sqlite3_shutdown when it stops. Since we don't
always use sqlite3, we initialize it when a SQLiteDatabse is constructed
(calling sqlite3_initialize after initialized is a no-op). We call
sqlite3_shutdown when we see that there are no databases opened. The
number of open databases is tracked by an atomic g_dbs_open.
2020-10-14 11:28:18 -04:00
Andrew Chow 5a488b3d77 Constructors, destructors, and relevant private fields for SQLiteDatabase/Batch 2020-10-14 11:28:17 -04:00
Andrew Chow ca8b7e04ab Implement SQLiteDatabaseVersion 2020-10-14 11:27:40 -04:00
Andrew Chow 7577b6e1c8 Add SQLiteDatabase and SQLiteBatch dummy classes 2020-10-14 11:27:37 -04:00