-
Notifications
You must be signed in to change notification settings - Fork 573
Description
After migrating the sqlcipher from v 3.5.9 to v 4.2.0 , we are seeing a lot of crashes, mostly on
Galaxy S7, S8, A5(2017) & J7 Pro devices, with android version 8 & 9 installed.
The upgrade seems to work well for all the other users.
This is the hook used for the migration
SQLiteDatabaseHook hook = new SQLiteDatabaseHook() {
public void preKey(SQLiteDatabase database) {}
public void postKey(SQLiteDatabase database) {
singleValueFromQuery(database, "PRAGMA cipher_migrate");
}
};
public static String singleValueFromQuery(SQLiteDatabase database, String query) {
net.sqlcipher.Cursor cursor = database.rawQuery(query, new String[]{});
String value = "";
if (cursor != null) {
cursor.moveToFirst();
value = cursor.getString(0);
cursor.close();
}
return value;
}
The database exists, the password is correct, but the migration fails it seems and the app crashes. When i provide the users an apk with old v3.5.9 sqlcipher build after they have installed the new build with v4.2.0, everything works again.
Here is the Stack trace.
Caused by net.sqlcipher.database.SQLiteException
file is not a database: , while compiling: select count(*) from sqlite_master;
net.sqlcipher.database.SQLiteCompiledSql.native_compile (SQLiteCompiledSql.java)
net.sqlcipher.database.SQLiteCompiledSql.compile (SQLiteCompiledSql.java:91)
net.sqlcipher.database.SQLiteCompiledSql. (SQLiteCompiledSql.java:12)
net.sqlcipher.database.SQLiteProgram. (SQLiteProgram.java:18)
net.sqlcipher.database.SQLiteQuery. (SQLiteQuery.java:1)
net.sqlcipher.database.SQLiteDirectCursorDriver.query (SQLiteDirectCursorDriver.java:60)
net.sqlcipher.database.SQLiteDatabase.rawQueryWithFactory (SQLiteDatabase.java:2012)
net.sqlcipher.database.SQLiteDatabase.rawQuery (SQLiteDatabase.java:1898)
net.sqlcipher.database.SQLiteDatabase.keyDatabase (SQLiteDatabase.java:2647)
net.sqlcipher.database.SQLiteDatabase.openDatabaseInternal (SQLiteDatabase.java:2577)
net.sqlcipher.database.SQLiteDatabase.openDatabase (SQLiteDatabase.java:1243)
net.sqlcipher.database.SQLiteDatabase.openDatabase (SQLiteDatabase.java:1210)
net.sqlcipher.database.SQLiteDatabase.openOrCreateDatabase (SQLiteDatabase.java:1300)
net.sqlcipher.database.SQLiteDatabase.openOrCreateDatabase (SQLiteDatabase.java:1288)
net.sqlcipher.database.SQLiteDatabase.openOrCreateDatabase (SQLiteDatabase.java:1280)
net.sqlcipher.database.SQLiteDatabase.openOrCreateDatabase (SQLiteDatabase.java:1325)
com.pixelcrater.Diaro.storage.sqlite.helpers.SQLiteMgr.getCipherEncryptedDb (SQLiteMgr.java:83)
com.pixelcrater.Diaro.storage.sqlite.SQLiteAdapter. (SQLiteAdapter.java:10)
com.pixelcrater.Diaro.storage.StorageMgr.getSQLiteAdapter (StorageMgr.java:44)
com.pixelcrater.Diaro.storage.StorageMgr. (StorageMgr.java:4)
com.pixelcrater.Diaro.MyApp.onCreate (MyApp.java:145)
We also noticed, that a lot of users were complaining about how slow the app has become, and after running some tests, we found out that using this makes sqlcipher faster again :
encryptedDb.execSQL("PRAGMA cipher_memory_security = OFF");