Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix memory leak with crypt keys |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | sourceforge |
Files: | files | file ages | folders |
SHA1: |
659d427be4dd6ffce3a792e7c944d782 |
User & Date: | rmsimpson 2006-01-12 20:53:00.000 |
Context
2006-01-12
| ||
20:53 | Automate fixing up of sqlite sources check-in: f89ae9878e user: rmsimpson tags: sourceforge | |
20:53 | Fix memory leak with crypt keys check-in: 659d427be4 user: rmsimpson tags: sourceforge | |
20:51 | Jan 12 SQLite CVS HEAD check-in: 0ca16298cf user: rmsimpson tags: sourceforge | |
Changes
Changes to SQLite.Interop/crypt.c.
1 2 3 4 5 6 7 8 | #include "src/pager.c" #ifndef SQLITE_OMIT_DISKIO #ifdef SQLITE_HAS_CODEC #include <windows.h> #include <wincrypt.h> | > > > > < < < < > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | #ifdef SQLITE_HAS_CODEC void sqlite3pager_free_codecarg(void *pArg); #endif #include "src/pager.c" #ifndef SQLITE_OMIT_DISKIO #ifdef SQLITE_HAS_CODEC #include <windows.h> #include <wincrypt.h> typedef struct _CRYPTBLOCK { HCRYPTKEY hReadKey; // Key used to read from the database and write to the journal HCRYPTKEY hWriteKey; // Key used to write to the database DWORD dwPageSize; // Size of pages LPVOID pvCrypt; // A buffer for encrypting/decrypting (if necessary) DWORD dwCryptSize; // Equal to or greater than dwPageSize. If larger, pvCrypt is valid and this is its size } CRYPTBLOCK, *LPCRYPTBLOCK; HCRYPTPROV g_hProvider = 0; // Global instance of the cryptographic provider #define SQLITECRYPTERROR_PROVIDER "Cryptographic provider not available" // Needed for re-keying static void * sqlite3pager_get_codecarg(Pager *pPager) { return (pPager->xCodec) ? pPager->pCodecArg: NULL; } |
︙ | ︙ | |||
246 247 248 249 250 251 252 253 254 255 256 257 258 259 | { LPCRYPTBLOCK pBlock = CreateCryptBlock(hKey, sqlite3BtreePager(db->aDb[nDb].pBt), NULL); sqlite3pager_set_codec(sqlite3BtreePager(db->aDb[nDb].pBt), sqlite3Codec, pBlock); rc = SQLITE_OK; } return rc; } // Once a password has been supplied and a key created, we don't keep the // original password for security purposes. Therefore return NULL. void sqlite3CodecGetKey(sqlite3 *db, int nDb, void **ppKey, int *pnKeyLen) { *ppKey = NULL; *pnKeyLen = 0; | > > > > > > > > > > > > > > > > > | 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | { LPCRYPTBLOCK pBlock = CreateCryptBlock(hKey, sqlite3BtreePager(db->aDb[nDb].pBt), NULL); sqlite3pager_set_codec(sqlite3BtreePager(db->aDb[nDb].pBt), sqlite3Codec, pBlock); rc = SQLITE_OK; } return rc; } void sqlite3pager_free_codecarg(void *pArg) { LPCRYPTBLOCK pBlock = (LPCRYPTBLOCK)pArg; if (pBlock) { if (pBlock->hReadKey) CryptDestroyKey(pBlock->hReadKey); if (pBlock->hWriteKey) CryptDestroyKey(pBlock->hWriteKey); if (pBlock->pvCrypt) free(pBlock->pvCrypt); } free(pBlock); } // Once a password has been supplied and a key created, we don't keep the // original password for security purposes. Therefore return NULL. void sqlite3CodecGetKey(sqlite3 *db, int nDb, void **ppKey, int *pnKeyLen) { *ppKey = NULL; *pnKeyLen = 0; |
︙ | ︙ |