diff options
author | jason <jason.gabriele@dexcom.com> | 2019-12-13 20:47:53 +0300 |
---|---|---|
committer | jason <jason.gabriele@dexcom.com> | 2019-12-13 20:47:53 +0300 |
commit | d92d1285ce926de311d0998cc8559934902bfeda (patch) | |
tree | 9975adb809b0a48f446c891837bfbd5a6df9116c | |
parent | 9b100cc3dd83ff88a17a4da8718eab4b08e2fe67 (diff) |
Check that we are actually connected to an SQLCipher db
-rw-r--r-- | src/fmdb/FMDatabase.m | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/fmdb/FMDatabase.m b/src/fmdb/FMDatabase.m index e91a09b..205fe92 100644 --- a/src/fmdb/FMDatabase.m +++ b/src/fmdb/FMDatabase.m @@ -497,12 +497,29 @@ static int FMDBDatabaseBusyHandler(void *f, int count) { return NO; } +#ifdef SQLITE_HAS_CODEC + // Starting with Xcode8 / iOS 10 we check to make sure we really are linked with + // SQLCipher because there is no longer a linker error if we accidently link + // with unencrypted sqlite library. + // + // https://discuss.zetetic.net/t/important-advisory-sqlcipher-with-xcode-8-and-new-sdks/1688 + + FMResultSet *rs = [self executeQuery:@"PRAGMA cipher_version"]; + + if ([rs next]) { + NSLog(@"SQLCipher version: %@", rs.resultDictionary[@"cipher_version"]); + + [rs close]; + return YES; + } +#else FMResultSet *rs = [self executeQuery:@"select name from sqlite_master where type='table'"]; if (rs) { [rs close]; return YES; } +#endif return NO; } |