Skip to content

Commit 5bc2e09

Browse files
committed
don't treat SQLITE_NOTADB error as a corruption because it can occur with mismatched keys
1 parent 6458f14 commit 5bc2e09

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

sqlcipher/src/main/jni/sqlcipher/android_database_SQLiteCommon.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,14 @@ void throw_sqlite3_exception(JNIEnv* env, int errcode,
6868
exceptionClass = "android/database/sqlite/SQLiteDiskIOException";
6969
break;
7070
case SQLITE_CORRUPT:
71-
case SQLITE_NOTADB: // treat "unsupported file format" error as corruption also
7271
exceptionClass = "android/database/sqlite/SQLiteDatabaseCorruptException";
7372
break;
73+
case SQLITE_NOTADB:
74+
/* Upstream treats treat "unsupported file format" error as corruption (SQLiteDatabaseCorruptException).
75+
However, SQLITE_NOTADB can occur with mismatched keys, which is not a corruption case, so SQLCipher
76+
treats this as a general exception */
77+
exceptionClass = "android/database/sqlite/SQLiteException";
78+
break;
7479
case SQLITE_CONSTRAINT:
7580
exceptionClass = "android/database/sqlite/SQLiteConstraintException";
7681
break;

0 commit comments

Comments
 (0)