1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-14 00:22:38 +03:00

Restore the hexrekey pragma which was accidently deleted during the

pragma refactoring.  Make sure the hexkey and hexrekey pragmas do not
overflow buffers with a over-length key.

FossilOrigin-Name: 0aca31e1514b3df254c049b4251bcb199831681a
This commit is contained in:
drh
2013-10-07 00:36:01 +00:00
parent 793eb043ce
commit 8ab88326cb
4 changed files with 22 additions and 14 deletions

View File

@@ -208,6 +208,10 @@ static const struct sPragmaNames {
/* ePragTyp: */ PragTyp_HEXKEY,
/* ePragFlag: */ 0,
/* iArg: */ 0 },
{ /* zName: */ "hexrekey",
/* ePragTyp: */ PragTyp_HEXKEY,
/* ePragFlag: */ 0,
/* iArg: */ 0 },
#endif
#if !defined(SQLITE_OMIT_CHECK)
{ /* zName: */ "ignore_check_constraints",
@@ -416,7 +420,7 @@ static const struct sPragmaNames {
/* ePragFlag: */ 0,
/* iArg: */ SQLITE_WriteSchema|SQLITE_RecoveryMode },
};
/* Number of pragmas: 55 on by default, 66 total. */
/* Number of pragmas: 55 on by default, 67 total. */
/* End of the automatically generated pragma table.
***************************************************************************/
@@ -2177,12 +2181,12 @@ void sqlite3Pragma(
}
case PragTyp_HEXKEY: {
if( zRight ){
int i, h1, h2;
u8 iByte;
int i;
char zKey[40];
for(i=0; (h1 = zRight[i])!=0 && (h2 = zRight[i+1])!=0; i+=2){
h1 += 9*(1&(h1>>6));
h2 += 9*(1&(h2>>6));
zKey[i/2] = (h2 & 0x0f) | ((h1 & 0xf)<<4);
for(i=0, iByte=0; i<sizeof(zKey)*2 && sqlite3Isxdigit(zRight[i]); i++){
iByte = (iByte<<4) + sqlite3HexToInt(zRight[i]);
if( (i&1)!=0 ) zKey[i/2] = iByte;
}
if( (zLeft[3] & 0xf)==0xb ){
sqlite3_key_v2(db, zDb, zKey, i/2);