From 98a3a3f872568a5ac99da13e027fe2e91d147719 Mon Sep 17 00:00:00 2001 From: "Kenneth J. Shackleton" Date: Sat, 9 Sep 2023 08:40:12 +0100 Subject: [PATCH 1/4] SQLCipher 4.5.5. Signed-off-by: Kenneth J. Shackleton --- gradle.properties | 2 +- .../test/kotlin/com/bloomberg/selekt/android/SelektTest.kt | 4 ++-- selekt-sqlite3/src/main/external/sqlcipher | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gradle.properties b/gradle.properties index 6703a04a7f..b151d9cbab 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ openssl.version.suffix=u openssl.sha256=e2f8d84b523eecd06c7be7626830370300fbcc15386bf5142d72758f6963ebc6 openssl.pgp.sha256=7f564cada05f055c1534eae3fc7c19864eb2f6831cfcd91546e62476ba99e96e -sqlcipher.versionName=4.5.4 +sqlcipher.versionName=4.5.5 org.gradle.caching=true org.gradle.configuration-cache=true diff --git a/selekt-android/src/test/kotlin/com/bloomberg/selekt/android/SelektTest.kt b/selekt-android/src/test/kotlin/com/bloomberg/selekt/android/SelektTest.kt index 497bc717bd..ed4522ddda 100644 --- a/selekt-android/src/test/kotlin/com/bloomberg/selekt/android/SelektTest.kt +++ b/selekt-android/src/test/kotlin/com/bloomberg/selekt/android/SelektTest.kt @@ -35,12 +35,12 @@ internal class SelektTest { @Test fun libVersion() { - assertEquals("3.41.2", Selekt.sqliteLibVersion()) + assertEquals("3.42.0", Selekt.sqliteLibVersion()) } @Test fun libVersionNumber() { - assertEquals(3_041_002, Selekt.sqliteLibVersionNumber()) + assertEquals(3_042_000, Selekt.sqliteLibVersionNumber()) } @OptIn(Experimental::class) diff --git a/selekt-sqlite3/src/main/external/sqlcipher b/selekt-sqlite3/src/main/external/sqlcipher index c7f9a1c348..7c460791eb 160000 --- a/selekt-sqlite3/src/main/external/sqlcipher +++ b/selekt-sqlite3/src/main/external/sqlcipher @@ -1 +1 @@ -Subproject commit c7f9a1c348fde215ac18ce2b78a62ce8111a3743 +Subproject commit 7c460791eba939e6c6872825219a6644ca47283b From 5c3d8d9524ad11a734ad4904fd25c60074c9095b Mon Sep 17 00:00:00 2001 From: "Kenneth J. Shackleton" Date: Sat, 9 Sep 2023 10:18:21 +0100 Subject: [PATCH 2/4] Assert in test that re-key without first keying fails. Signed-off-by: Kenneth J. Shackleton --- .../test/kotlin/com/bloomberg/selekt/android/SQLiteTest.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/selekt-android/src/test/kotlin/com/bloomberg/selekt/android/SQLiteTest.kt b/selekt-android/src/test/kotlin/com/bloomberg/selekt/android/SQLiteTest.kt index 0c037a6f82..9950a7a8ca 100644 --- a/selekt-android/src/test/kotlin/com/bloomberg/selekt/android/SQLiteTest.kt +++ b/selekt-android/src/test/kotlin/com/bloomberg/selekt/android/SQLiteTest.kt @@ -16,6 +16,7 @@ package com.bloomberg.selekt.android +import android.database.SQLException import android.database.sqlite.SQLiteAbortException import android.database.sqlite.SQLiteBindOrColumnIndexOutOfRangeException import android.database.sqlite.SQLiteBlobTooBigException @@ -142,8 +143,10 @@ internal class SQLiteTest { } @Test - fun openThenRekeySuccessfully() { - assertEquals(SQL_OK, SQLite.rekey(db, otherKey)) + fun openThenRekeyWithoutKeyFails() { + assertFailsWith { + SQLite.rekey(db, otherKey) + } } @Test From 5778152954442d18f5930e6177d6453794f8660b Mon Sep 17 00:00:00 2001 From: "Kenneth J. Shackleton" Date: Sat, 9 Sep 2023 10:19:43 +0100 Subject: [PATCH 3/4] Return SQL_OK directly. Signed-off-by: Kenneth J. Shackleton --- .../src/main/kotlin/com/bloomberg/selekt/SQLite.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/selekt-java/src/main/kotlin/com/bloomberg/selekt/SQLite.kt b/selekt-java/src/main/kotlin/com/bloomberg/selekt/SQLite.kt index 828906613d..fa952cc3c1 100644 --- a/selekt-java/src/main/kotlin/com/bloomberg/selekt/SQLite.kt +++ b/selekt-java/src/main/kotlin/com/bloomberg/selekt/SQLite.kt @@ -260,26 +260,26 @@ open class SQLite( throwSQLException(errorCode(db), extendedErrorCode(db), errorMessage(db), context) private fun checkSQLCode(code: SQLCode): SQLCode = when (code) { - SQL_OK -> code + SQL_OK -> SQL_OK else -> throwSQLException(code, -1, "Error information not accessible.") } private fun checkConnectionSQLCode(db: Long, code: SQLCode): SQLCode { if (SQL_OK == code) { - return code + return SQL_OK } throwSQLException(db) } private fun checkStatementSQLCode(statement: Long, code: SQLCode): SQLCode = if (SQL_OK == code) { - code + SQL_OK } else { throwSQLException(databaseHandle(statement)) } private fun checkBindSQLCode(statement: Long, code: SQLCode): SQLCode { if (SQL_OK == code) { - return code + return SQL_OK } throwSQLException(databaseHandle(statement)) } From fbac4d697705271f04c5355672caacf82907a578 Mon Sep 17 00:00:00 2001 From: "Kenneth J. Shackleton" Date: Sat, 9 Sep 2023 10:31:47 +0100 Subject: [PATCH 4/4] Allow failing by throwing an SQLiteException. Signed-off-by: Kenneth J. Shackleton --- .../src/main/kotlin/com/bloomberg/selekt/android/SQLite.kt | 2 -- .../test/kotlin/com/bloomberg/selekt/android/SQLiteTest.kt | 5 ++--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/selekt-android/src/main/kotlin/com/bloomberg/selekt/android/SQLite.kt b/selekt-android/src/main/kotlin/com/bloomberg/selekt/android/SQLite.kt index cf3899aa12..0e07d848da 100644 --- a/selekt-android/src/main/kotlin/com/bloomberg/selekt/android/SQLite.kt +++ b/selekt-android/src/main/kotlin/com/bloomberg/selekt/android/SQLite.kt @@ -48,7 +48,6 @@ import com.bloomberg.selekt.SQL_MISUSE import com.bloomberg.selekt.SQL_NOMEM import com.bloomberg.selekt.SQL_NOT_A_DATABASE import com.bloomberg.selekt.SQL_NOT_FOUND -import com.bloomberg.selekt.SQL_OK import com.bloomberg.selekt.SQL_RANGE import com.bloomberg.selekt.SQL_READONLY import com.bloomberg.selekt.SQL_TOO_BIG @@ -91,7 +90,6 @@ internal object SQLite : com.bloomberg.selekt.SQLite(sqlite) { message: String, context: String? ): Nothing { - require(code != SQL_OK) { "Result code is not an error: $code" } val exceptionMessage = extendedErrorMessage(code, extendedCode, message, context) throw when (code) { SQL_BUSY -> SQLiteDatabaseLockedException(exceptionMessage) diff --git a/selekt-android/src/test/kotlin/com/bloomberg/selekt/android/SQLiteTest.kt b/selekt-android/src/test/kotlin/com/bloomberg/selekt/android/SQLiteTest.kt index 9950a7a8ca..0fe8e9af4c 100644 --- a/selekt-android/src/test/kotlin/com/bloomberg/selekt/android/SQLiteTest.kt +++ b/selekt-android/src/test/kotlin/com/bloomberg/selekt/android/SQLiteTest.kt @@ -16,7 +16,6 @@ package com.bloomberg.selekt.android -import android.database.SQLException import android.database.sqlite.SQLiteAbortException import android.database.sqlite.SQLiteBindOrColumnIndexOutOfRangeException import android.database.sqlite.SQLiteBlobTooBigException @@ -144,7 +143,7 @@ internal class SQLiteTest { @Test fun openThenRekeyWithoutKeyFails() { - assertFailsWith { + assertFailsWith { SQLite.rekey(db, otherKey) } } @@ -738,7 +737,7 @@ internal class SQLiteTest { @Test fun exceptionForErrorOk() { - assertFailsWith { + assertFailsWith { SQLite.throwSQLException(SQL_OK, SQL_OK, "") } }