@@ -389,10 +389,9 @@ static int sqlcipher_cipher_ctx_set_keyspec(cipher_ctx *ctx, const unsigned char
389
389
390
390
ctx -> keyspec [0 ] = 'x' ;
391
391
ctx -> keyspec [1 ] = '\'' ;
392
- ctx -> keyspec [ctx -> keyspec_sz - 1 ] = '\'' ;
393
392
cipher_bin2hex (key , key_sz , ctx -> keyspec + 2 );
394
393
cipher_bin2hex (salt , salt_sz , ctx -> keyspec + (key_sz * 2 ) + 2 );
395
-
394
+ ctx -> keyspec [ ctx -> keyspec_sz - 1 ] = '\'' ;
396
395
return SQLITE_OK ;
397
396
}
398
397
@@ -980,15 +979,9 @@ int sqlcipher_codec_ctx_migrate(codec_ctx *ctx) {
980
979
memcpy (key , ctx -> read_ctx -> pass , ctx -> read_ctx -> pass_sz );
981
980
982
981
if (db_filename ){
983
-
982
+ const char * commands [ 4 ];
984
983
char * attach_command = sqlite3_mprintf ("ATTACH DATABASE '%s-migrated' as migrate KEY '%s';" ,
985
984
db_filename , key );
986
- const char * commands [] = {
987
- upgrade_4k_format == 1 ? pragma_4k_kdf_iter : "" ,
988
- upgrade_1x_format == 1 ? pragma_hmac_off : "" ,
989
- attach_command ,
990
- "SELECT sqlcipher_export('migrate');" ,
991
- };
992
985
993
986
int rc = sqlcipher_check_connection (db_filename , key , key_sz , "" );
994
987
if (rc == SQLITE_OK ){
@@ -1019,7 +1012,11 @@ int sqlcipher_codec_ctx_migrate(codec_ctx *ctx) {
1019
1012
goto handle_error ;
1020
1013
}
1021
1014
1022
-
1015
+ commands [0 ] = upgrade_4k_format == 1 ? pragma_4k_kdf_iter : "" ;
1016
+ commands [1 ] = upgrade_1x_format == 1 ? pragma_hmac_off : "" ;
1017
+ commands [2 ] = attach_command ;
1018
+ commands [3 ] = "SELECT sqlcipher_export('migrate');" ;
1019
+
1023
1020
for (command_idx = 0 ; command_idx < (sizeof (commands )/sizeof (commands [0 ])); command_idx ++ ){
1024
1021
const char * command = commands [command_idx ];
1025
1022
if (strcmp (command , "" ) == 0 ){
0 commit comments