From 8ab88326cbb8ce03fd5c86e62fdb9faefd352956 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 7 Oct 2013 00:36:01 +0000 Subject: [PATCH] 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 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/pragma.c | 16 ++++++++++------ tool/mkpragmatab.tcl | 4 ++++ 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 41ee89f9cb..f73f1c1ded 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sincorrect\sdebugging\sassert()\sthat\swas\saccidently\sadded\sduring\sthe\nSTAT4\senhancement. -D 2013-10-06T22:52:51.495 +C Restore\sthe\shexrekey\spragma\swhich\swas\saccidently\sdeleted\sduring\sthe\npragma\srefactoring.\s\sMake\ssure\sthe\shexkey\sand\shexrekey\spragmas\sdo\snot\noverflow\sbuffers\swith\sa\sover-length\skey. +D 2013-10-07T00:36:01.510 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -210,7 +210,7 @@ F src/parse.y a97566d6da75075589a7c716d1bda14b586cf8da F src/pcache.c f8043b433a57aba85384a531e3937a804432a346 F src/pcache.h a5e4f5d9f5d592051d91212c5949517971ae6222 F src/pcache1.c a467393909a4ed7ca9de066d85ba5c5b04a5be63 -F src/pragma.c 5a4d8d9c3c7d22ef920487a260ea3d4b59d3b3a6 +F src/pragma.c b65c8273162818095cfd2dd37bbbf791710de560 F src/prepare.c fa6988589f39af8504a61731614cd4f6ae71554f F src/printf.c da9119eb31a187a4b99f60aa4a225141c0ebb74b F src/random.c 0b2dbc37fdfbfa6bd455b091dfcef5bdb32dba68 @@ -1088,7 +1088,7 @@ F tool/lempar.c 01ca97f87610d1dac6d8cd96ab109ab1130e76dc F tool/mkautoconfamal.sh f8d8dbf7d62f409ebed5134998bf5b51d7266383 F tool/mkkeywordhash.c bb52064aa614e1426445e4b2b9b00eeecd23cc79 F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e -F tool/mkpragmatab.tcl 33fa7a6e824b14f7b04109ed75b19f3e9e228412 +F tool/mkpragmatab.tcl ceaaeebcd882864caefe4176592ca6fa4648fab1 F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 F tool/mksqlite3c-noext.tcl 8bce31074e4cbe631bb7676526a048335f4c9f02 F tool/mksqlite3c.tcl d344cc3144a0271cd853c5e3df36e9f31d78d619 @@ -1121,7 +1121,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 087af29ee2e1572f8668dd0152a14d7f9796a530 -R 51b296de6c6fe46f937c9d0db2bd86cb +P 2bb7f74bbd467b74581699d16b06758f9c9457dc +R cb77936fe5ecaea76a165316bdd4333b U drh -Z e830bdf0fada797e73e5410e79960d79 +Z 43e1a965446b3e0121e18fe95479d9fc diff --git a/manifest.uuid b/manifest.uuid index 9fa53530b1..4aae2f1188 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2bb7f74bbd467b74581699d16b06758f9c9457dc \ No newline at end of file +0aca31e1514b3df254c049b4251bcb199831681a \ No newline at end of file diff --git a/src/pragma.c b/src/pragma.c index f533b71c21..4e5d012a95 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -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