/ Check-in [0aca31e1]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment: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.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 0aca31e1514b3df254c049b4251bcb199831681a
User & Date: drh 2013-10-07 00:36:01
Context
2013-10-07
21:49
Fix compilation issue with MSVC. check-in: 36d64dc3 user: mistachkin tags: trunk
10:48
Merge bug fixes from trunk. check-in: 1d7b2dc0 user: drh tags: row-size-est
00:36
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. check-in: 0aca31e1 user: drh tags: trunk
2013-10-06
22:52
Remove an incorrect debugging assert() that was accidently added during the STAT4 enhancement. check-in: 2bb7f74b user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/pragma.c.

   204    204       /* ePragFlag: */ 0,
   205    205       /* iArg:      */ SQLITE_FullFSync },
   206    206   #if defined(SQLITE_HAS_CODEC)
   207    207     { /* zName:     */ "hexkey",
   208    208       /* ePragTyp:  */ PragTyp_HEXKEY,
   209    209       /* ePragFlag: */ 0,
   210    210       /* iArg:      */ 0 },
          211  +  { /* zName:     */ "hexrekey",
          212  +    /* ePragTyp:  */ PragTyp_HEXKEY,
          213  +    /* ePragFlag: */ 0,
          214  +    /* iArg:      */ 0 },
   211    215   #endif
   212    216   #if !defined(SQLITE_OMIT_CHECK)
   213    217     { /* zName:     */ "ignore_check_constraints",
   214    218       /* ePragTyp:  */ PragTyp_FLAG,
   215    219       /* ePragFlag: */ 0,
   216    220       /* iArg:      */ SQLITE_IgnoreChecks },
   217    221   #endif
................................................................................
   412    416       /* iArg:      */ 0 },
   413    417   #endif
   414    418     { /* zName:     */ "writable_schema",
   415    419       /* ePragTyp:  */ PragTyp_FLAG,
   416    420       /* ePragFlag: */ 0,
   417    421       /* iArg:      */ SQLITE_WriteSchema|SQLITE_RecoveryMode },
   418    422   };
   419         -/* Number of pragmas: 55 on by default, 66 total. */
          423  +/* Number of pragmas: 55 on by default, 67 total. */
   420    424   /* End of the automatically generated pragma table.
   421    425   ***************************************************************************/
   422    426   
   423    427   /*
   424    428   ** Interpret the given string as a safety level.  Return 0 for OFF,
   425    429   ** 1 for ON or NORMAL and 2 for FULL.  Return 1 for an empty or 
   426    430   ** unrecognized string argument.  The FULL option is disallowed
................................................................................
  2173   2177     }
  2174   2178     case PragTyp_REKEY: {
  2175   2179       if( zRight ) sqlite3_rekey_v2(db, zDb, zRight, sqlite3Strlen30(zRight));
  2176   2180       break;
  2177   2181     }
  2178   2182     case PragTyp_HEXKEY: {
  2179   2183       if( zRight ){
  2180         -      int i, h1, h2;
         2184  +      u8 iByte;
         2185  +      int i;
  2181   2186         char zKey[40];
  2182         -      for(i=0; (h1 = zRight[i])!=0 && (h2 = zRight[i+1])!=0; i+=2){
  2183         -        h1 += 9*(1&(h1>>6));
  2184         -        h2 += 9*(1&(h2>>6));
  2185         -        zKey[i/2] = (h2 & 0x0f) | ((h1 & 0xf)<<4);
         2187  +      for(i=0, iByte=0; i<sizeof(zKey)*2 && sqlite3Isxdigit(zRight[i]); i++){
         2188  +        iByte = (iByte<<4) + sqlite3HexToInt(zRight[i]);
         2189  +        if( (i&1)!=0 ) zKey[i/2] = iByte;
  2186   2190         }
  2187   2191         if( (zLeft[3] & 0xf)==0xb ){
  2188   2192           sqlite3_key_v2(db, zDb, zKey, i/2);
  2189   2193         }else{
  2190   2194           sqlite3_rekey_v2(db, zDb, zKey, i/2);
  2191   2195         }
  2192   2196       }

Changes to tool/mkpragmatab.tcl.

   250    250   
   251    251     NAME: rekey
   252    252     IF:   defined(SQLITE_HAS_CODEC)
   253    253   
   254    254     NAME: hexkey
   255    255     IF:   defined(SQLITE_HAS_CODEC)
   256    256   
          257  +  NAME: hexrekey
          258  +  TYPE: HEXKEY
          259  +  IF:   defined(SQLITE_HAS_CODEC)
          260  +
   257    261     NAME: activate_extensions
   258    262     IF:   defined(SQLITE_HAS_CODEC) || defined(SQLITE_ENABLE_CEROD)
   259    263   
   260    264     NAME: soft_heap_limit
   261    265   }
   262    266   set name {}
   263    267   set type {}