You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With 1.5.1, sqlite3_key crashes with a NULL pointer (both VS22 and gcc).
Call stack :
.exe!sqlite3mcGetCipherParameter(_CipherParams * cipherParams, const char * paramName) Line 39 C
.exe!AllocateChaCha20Cipher(sqlite3 * db) Line 73 C
.exe!sqlite3mcCodecSetup(_Codec * codec, int cipherType, char * userPassword, int passwordLength) Line 251 C
.exe!sqlite3mcCodecAttach(sqlite3 * db, int nDb, const char * zKey, const void * nKey, int) Line 280 C
.exe!sqlite3_key_v2(sqlite3 * db, const char * zDbName, const void * zKey, int nKey) Line 359 C
At some point, sqlite3mcGetCipherParams returns a NULL cipherParams pointer that is passed to sqlite3mcGetCipherParameter.
static void*
AllocateChaCha20Cipher(sqlite3* db)
{
ChaCha20Cipher* chacha20Cipher = (ChaCha20Cipher*) sqlite3_malloc(sizeof(ChaCha20Cipher));
if (chacha20Cipher != NULL)
{
memset(chacha20Cipher, 0, sizeof(ChaCha20Cipher));
chacha20Cipher->m_keyLength = KEYLENGTH_CHACHA20;
memset(chacha20Cipher->m_key, 0, KEYLENGTH_CHACHA20);
memset(chacha20Cipher->m_salt, 0, SALTLENGTH_CHACHA20);
}
if (chacha20Cipher != NULL)
{
CipherParams* cipherParams = sqlite3mcGetCipherParams(db, CODEC_TYPE_CHACHA20); <<<<========= cipherParams is NULL at some point
chacha20Cipher->m_legacy = sqlite3mcGetCipherParameter(cipherParams, "legacy"); <<<<========= cipherParams used without a NULL check
chacha20Cipher->m_legacyPageSize = sqlite3mcGetCipherParameter(cipherParams, "legacy_page_size");
chacha20Cipher->m_kdfIter = sqlite3mcGetCipherParameter(cipherParams, "kdf_iter");
if (chacha20Cipher->m_legacy != 0)
{
chacha20Cipher->m_kdfIter = SQLEET_KDF_ITER;
}
}
return chacha20Cipher;
}
Without the #defines everything is ok (both VS22 and gcc).
Can you reproduce ?
The text was updated successfully, but these errors were encountered:
Thanks for reporting. I will take a closer look later today. Most likely I forgot to adjust the code for configuration parameter retrieval to the new cipher scheme registration approach.
If some of the builtin cipher schemes are omitted, the retrieval of the cipher configuration parameter table can return an invalid pointer, leading to a crash on activating encryption for a database connection.
Hi,
I have used this #define configuration in my applications till now.
HAVE_CIPHER_AES_128_CBC=0
HAVE_CIPHER_AES_256_CBC=0
HAVE_CIPHER_SQLCIPHER=0
HAVE_CIPHER_RC4=0
HAVE_CIPHER_CHACHA20=1
CODEC_TYPE=CODEC_TYPE_CHACHA20
With 1.5.1, sqlite3_key crashes with a NULL pointer (both VS22 and gcc).
Call stack :
.exe!sqlite3mcGetCipherParameter(_CipherParams * cipherParams, const char * paramName) Line 39 C
.exe!AllocateChaCha20Cipher(sqlite3 * db) Line 73 C
.exe!sqlite3mcCodecSetup(_Codec * codec, int cipherType, char * userPassword, int passwordLength) Line 251 C
.exe!sqlite3mcCodecAttach(sqlite3 * db, int nDb, const char * zKey, const void * nKey, int) Line 280 C
.exe!sqlite3_key_v2(sqlite3 * db, const char * zDbName, const void * zKey, int nKey) Line 359 C
At some point, sqlite3mcGetCipherParams returns a NULL cipherParams pointer that is passed to sqlite3mcGetCipherParameter.
static void*
AllocateChaCha20Cipher(sqlite3* db)
{
ChaCha20Cipher* chacha20Cipher = (ChaCha20Cipher*) sqlite3_malloc(sizeof(ChaCha20Cipher));
if (chacha20Cipher != NULL)
{
memset(chacha20Cipher, 0, sizeof(ChaCha20Cipher));
chacha20Cipher->m_keyLength = KEYLENGTH_CHACHA20;
memset(chacha20Cipher->m_key, 0, KEYLENGTH_CHACHA20);
memset(chacha20Cipher->m_salt, 0, SALTLENGTH_CHACHA20);
}
if (chacha20Cipher != NULL)
{
CipherParams* cipherParams = sqlite3mcGetCipherParams(db, CODEC_TYPE_CHACHA20); <<<<========= cipherParams is NULL at some point
chacha20Cipher->m_legacy = sqlite3mcGetCipherParameter(cipherParams, "legacy"); <<<<========= cipherParams used without a NULL check
chacha20Cipher->m_legacyPageSize = sqlite3mcGetCipherParameter(cipherParams, "legacy_page_size");
chacha20Cipher->m_kdfIter = sqlite3mcGetCipherParameter(cipherParams, "kdf_iter");
if (chacha20Cipher->m_legacy != 0)
{
chacha20Cipher->m_kdfIter = SQLEET_KDF_ITER;
}
}
return chacha20Cipher;
}
Can you reproduce ?
The text was updated successfully, but these errors were encountered: