From 867d0dafd52dc7047a4009d36b335ac7cb059fa4 Mon Sep 17 00:00:00 2001 From: Stephen Lombardo Date: Thu, 27 Sep 2018 10:32:13 -0400 Subject: [PATCH] SQLCIPHER_PROFILE_USE_FOPEN can force cipher_profile to use fopen (e.g. for WinXP) --- src/crypto_impl.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/crypto_impl.c b/src/crypto_impl.c index 9166d69d..3b8475c7 100644 --- a/src/crypto_impl.c +++ b/src/crypto_impl.c @@ -1447,15 +1447,11 @@ int sqlcipher_cipher_profile(sqlite3 *db, const char *destination){ }else if(sqlite3StrICmp(destination, "off") == 0){ f = 0; }else{ -#if defined(_WIN32) && (__STDC_VERSION__ > 199901L) || defined(SQLITE_OS_WINRT) - if(fopen_s(&f, destination, "a") != 0){ +#if !defined(SQLCIPHER_PROFILE_USE_FOPEN) && (defined(_WIN32) && (__STDC_VERSION__ > 199901L) || defined(SQLITE_OS_WINRT)) + if(fopen_s(&f, destination, "a") != 0) return SQLITE_ERROR; #else - f = fopen(destination, "a"); - if(f == 0){ + if((f = fopen(destination, "a")) == 0) return SQLITE_ERROR; #endif - return SQLITE_ERROR; - } - } sqlite3_profile(db, sqlcipher_profile_callback, f); return SQLITE_OK;