8000 Use append mode, and fopen_s when applicable for cipher_profile · magic-coder/sqlcipher@a11341d · GitHub
[go: up one dir, main page]

Skip to content

Commit a11341d

Browse files
Use append mode, and fopen_s when applicable for cipher_profile
1 parent 714bff6 commit a11341d

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/crypto_impl.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,17 +1206,22 @@ int sqlcipher_codec_add_random(codec_ctx *ctx, const char *zRight, int random_sz
12061206

12071207
int sqlcipher_cipher_profile(sqlite3 *db, const char *destination){
12081208
FILE *f;
1209-
if( strcmp(destination,"stdout")==0 ){
1209+
if(sqlite3StrICmp(destination, "stdout") == 0){
12101210
f = stdout;
1211-
}else if( strcmp(destination, "stderr")==0 ){
1211+
}else if(sqlite3StrICmp(destination, "stderr") == 0){
12121212
f = stderr;
1213-
}else if( strcmp(destination, "off")==0 ){
1213+
}else if(sqlite3StrICmp(destination, "off") == 0){
12141214
f = 0;
12151215
}else{
1216-
f = fopen(destination, "wb");
1217-
if( f==0 ){
1218-
return SQLITE_ERROR;
1219-
}
1216+
#if defined(_WIN32) && (__STDC_VERSION__ > 199901L)
1217+
if(fopen_s(&f, destination, "a") != 0){
1218+
#else
1219+
f = fopen(destination, "a");
1220+
if(f == 0){
1221+
#endif
1222+
return SQLITE_ERROR;
1223+
}
1224+
12201225
}
12211226
sqlite3_profile(db, sqlcipher_profile_callback, f);
12221227
return SQLITE_OK;
@@ -1225,7 +1230,7 @@ int sqlcipher_cipher_profile(sqlite3 *db, const char *destination){
12251230
static void sqlcipher_profile_callback(void *file, const char *sql, sqlite3_uint64 run_time){
12261231
FILE *f = (FILE*)file;
12271232
double elapsed = run_time/1000000.0;
1228-
if( f ) fprintf(f, "Elapsed time:%.3f ms - %s\n", elapsed, sql);
1233+
if(f) fprintf(f, "Elapsed time:%.3f ms - %s\n", elapsed, sql);
12291234
}
12301235

12311236
int sqlcipher_codec_fips_status(codec_ctx *ctx) {

0 commit comments

Comments
 (0)
0