normalize attach behavior when key is not yet derived

This commit is contained in:
Stephen Lombardo
2019-01-15 13:15:51 -05:00
parent e72b34b24b
commit 42e655bf35
2 changed files with 67 additions and 3 deletions
+5 -3
View File
@@ -813,10 +813,12 @@ void sqlite3CodecGetKey(sqlite3* db, int nDb, void **zKey, int *nKey) {
codec_ctx *ctx = (codec_ctx*) sqlite3PagerGetCodec(pDb->pBt->pBt->pPager);
if(ctx) {
if(sqlcipher_codec_get_store_pass(ctx) == 1) {
/* pass back the keyspec from the codec, unless PRAGMA cipher_store_pass
is set or keyspec has not yet been derived, in which case pass
back the password key material */
sqlcipher_codec_get_keyspec(ctx, zKey, nKey);
if(sqlcipher_codec_get_store_pass(ctx) == 1 || *zKey == NULL) {
sqlcipher_codec_get_pass(ctx, zKey, nKey);
} else {
sqlcipher_codec_get_keyspec(ctx, zKey, nKey);
}
} else {
*zKey = NULL;