File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1127,14 +1127,15 @@ int sqlcipher_codec_ctx_migrate(codec_ctx *ctx) {
11271127int sqlcipher_codec_add_random (codec_ctx * ctx , const char * zRight ){
11281128 int random_sz = strlen (zRight );
11291129 if (random_sz == ((ctx -> read_ctx -> key_sz * 2 ) + 3 ) && sqlite3StrNICmp ((const char * )zRight ,"x'" , 2 ) == 0 ) {
1130+ int rc = 0 ;
11301131 unsigned char * random ;
11311132 int n = random_sz - 3 ; /* adjust for leading x' and tailing ' */
11321133 const unsigned char * z = (const unsigned char * )zRight + 2 ; /* adjust lead offset of x' */
11331134 CODEC_TRACE (("sqlcipher_codec_add_random: using raw random blob from hex\n" ));
11341135 random = sqlcipher_malloc (n );
11351136 memset (random , 0 , n );
11361137 cipher_hex2bin (z , n , random );
1137- int rc = ctx -> read_ctx -> provider -> add_random (ctx -> read_ctx -> provider_ctx , random , n );
1138+ rc = ctx -> read_ctx -> provider -> add_random (ctx -> read_ctx -> provider_ctx , random , n );
11381139 sqlcipher_free (random , n );
11391140 return rc ;
11401141 }
Original file line number Diff line number Diff line change @@ -47,14 +47,15 @@ static sqlite3_mutex* ltc_rand_mutex = NULL;
4747
4848static int sqlcipher_ltc_add_random (void * ctx , void * buffer , int length ) {
4949 ltc_ctx * ltc = (ltc_ctx * )ctx ;
50- int rc = 0 ;
50+ int rc , block_idx = 0 ;
5151 int block_count = length / random_block_sz ;
52+ const unsigned char * data = (const unsigned char * )buffer ;
5253#ifndef SQLCIPHER_LTC_NO_MUTEX_RAND
5354 sqlite3_mutex_enter (ltc_rand_mutex );
5455#endif
55- for (int block_idx = 0 ; block_idx < block_count ; block_idx ++ ){
56- rc = fortuna_add_entropy (buffer , random_block_sz , & (ltc -> prng ));
57- buffer += random_block_sz ;
56+ for (; block_idx < block_count ; block_idx ++ ){
57+ rc = fortuna_add_entropy (data , random_block_sz , & (ltc -> prng ));
58+ data += random_block_sz ;
5859 rc = rc != CRYPT_OK ? SQLITE_ERROR : SQLITE_OK ;
5960 if (rc != SQLITE_OK ) {
6061 break ;
You can’t perform that action at this time.
0 commit comments