diff options
author | August "Gus" Mueller <gus@flyingmeat.com> | 2019-12-14 00:20:57 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-14 00:20:57 +0300 |
commit | 9a98636848905f48b6b9a304f2b90f9b3c2c9c4a (patch) | |
tree | 58ac85518322a8cccc3ab27b4710a0110d0480b6 | |
parent | 9b100cc3dd83ff88a17a4da8718eab4b08e2fe67 (diff) | |
parent | 08daa09460e54cb5fb41aabcd39e193f9025530d (diff) |
Merge pull request #768 from niveus/Check-for-SQLCiphersw01master1612
Check that we are actually connected to an SQLCipher DB
-rw-r--r-- | FMDB.podspec | 2 | ||||
-rw-r--r-- | src/fmdb/FMDatabase.m | 17 |
2 files changed, 18 insertions, 1 deletions
diff --git a/FMDB.podspec b/FMDB.podspec index eb610dc..6cae00a 100644 --- a/FMDB.podspec +++ b/FMDB.podspec @@ -43,7 +43,7 @@ Pod::Spec.new do |s| ss.dependency 'SQLCipher', '~> 4.0' ss.source_files = 'src/fmdb/FM*.{h,m}' ss.exclude_files = 'src/fmdb.m' - ss.xcconfig = { 'OTHER_CFLAGS' => '$(inherited) -DSQLITE_HAS_CODEC -DHAVE_USLEEP=1', 'HEADER_SEARCH_PATHS' => 'SQLCipher' } + ss.xcconfig = { 'OTHER_CFLAGS' => '$(inherited) -DSQLITE_HAS_CODEC -DHAVE_USLEEP=1 -DSQLCIPHER_CRYPTO', 'HEADER_SEARCH_PATHS' => 'SQLCipher' } end end diff --git a/src/fmdb/FMDatabase.m b/src/fmdb/FMDatabase.m index e91a09b..332ec07 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 SQLCIPHER_CRYPTO + // 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; } |