Use append mode, and fopen_s when applicable for cipher_profile

This commit is contained in:
Nick Parker 2016-05-26 10:54:02 -05:00
parent 714bff612b
commit a11341d185
1 changed files with 13 additions and 8 deletions

View File

@ -1206,17 +1206,22 @@ int sqlcipher_codec_add_random(codec_ctx *ctx, const char *zRight, int random_sz
int sqlcipher_cipher_profile(sqlite3 *db, const char *destination){ int sqlcipher_cipher_profile(sqlite3 *db, const char *destination){
FILE *f; FILE *f;
if( strcmp(destination,"stdout")==0 ){ if(sqlite3StrICmp(destination, "stdout") == 0){
f = stdout; f = stdout;
}else if( strcmp(destination, "stderr")==0 ){ }else if(sqlite3StrICmp(destination, "stderr") == 0){
f = stderr; f = stderr;
}else if( strcmp(destination, "off")==0 ){ }else if(sqlite3StrICmp(destination, "off") == 0){
f = 0; f = 0;
}else{ }else{
f = fopen(destination, "wb"); #if defined(_WIN32) && (__STDC_VERSION__ > 199901L)
if(fopen_s(&f, destination, "a") != 0){
#else
f = fopen(destination, "a");
if(f == 0){ if(f == 0){
#endif
return SQLITE_ERROR; return SQLITE_ERROR;
} }
} }
sqlite3_profile(db, sqlcipher_profile_callback, f); sqlite3_profile(db, sqlcipher_profile_callback, f);
return SQLITE_OK; return SQLITE_OK;