/ Check-in [d22c99b6]
Login

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

Overview
Comment:Disable the delta checksum verification in RBU by default. Reenable it using -DRBU_ENABLE_DELTA_CKSUM, if desired.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: d22c99b6ba997179ef3ccd341d9c36d5213d699305d15942d82587a0bfd16f9d
User & Date: drh 2017-10-05 11:29:37
Context
2017-10-05
19:12
Fix the command-line shell so that the ".schema --indent" command does a better job of dealing with \r\n in the middle of a CREATE statement in the schema. check-in: 4258fb57 user: drh tags: trunk
11:29
Disable the delta checksum verification in RBU by default. Reenable it using -DRBU_ENABLE_DELTA_CKSUM, if desired. check-in: d22c99b6 user: drh tags: trunk
2017-10-04
18:26
Updates to requirements marks. check-in: 40964a4e user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/rbu/sqlite3rbu.c.

    92     92   #if defined(_WIN32_WCE)
    93     93   #include "windows.h"
    94     94   #endif
    95     95   
    96     96   /* Maximum number of prepared UPDATE statements held by this module */
    97     97   #define SQLITE_RBU_UPDATE_CACHESIZE 16
    98     98   
           99  +/* Delta checksums disabled by default.  Compile with -DRBU_ENABLE_DELTA_CKSUM
          100  +** to enable checksum verification.
          101  +*/
          102  +#ifndef RBU_ENABLE_DELTA_CKSUM
          103  +# define RBU_ENABLE_DELTA_CKSUM 0
          104  +#endif
          105  +
    99    106   /*
   100    107   ** Swap two objects of type TYPE.
   101    108   */
   102    109   #if !defined(SQLITE_AMALGAMATION)
   103    110   # define SWAP(TYPE,A,B) {TYPE t=A; A=B; B=t;}
   104    111   #endif
   105    112   
................................................................................
   466    473     }
   467    474     z--;
   468    475     *pLen -= z - zStart;
   469    476     *pz = (char*)z;
   470    477     return v;
   471    478   }
   472    479   
          480  +#if RBU_ENABLE_DELTA_CKSUM
   473    481   /*
   474    482   ** Compute a 32-bit checksum on the N-byte buffer.  Return the result.
   475    483   */
   476    484   static unsigned int rbuDeltaChecksum(const char *zIn, size_t N){
   477    485     const unsigned char *z = (const unsigned char *)zIn;
   478    486     unsigned sum0 = 0;
   479    487     unsigned sum1 = 0;
................................................................................
   500    508       case 3:   sum3 += (z[2] << 8);
   501    509       case 2:   sum3 += (z[1] << 16);
   502    510       case 1:   sum3 += (z[0] << 24);
   503    511       default:  ;
   504    512     }
   505    513     return sum3;
   506    514   }
          515  +#endif
   507    516   
   508    517   /*
   509    518   ** Apply a delta.
   510    519   **
   511    520   ** The output buffer should be big enough to hold the whole output
   512    521   ** file and a NUL terminator at the end.  The delta_output_size()
   513    522   ** routine will determine this size for you.
................................................................................
   530    539     int lenSrc,            /* Length of the source file */
   531    540     const char *zDelta,    /* Delta to apply to the pattern */
   532    541     int lenDelta,          /* Length of the delta */
   533    542     char *zOut             /* Write the output into this preallocated buffer */
   534    543   ){
   535    544     unsigned int limit;
   536    545     unsigned int total = 0;
   537         -#ifndef FOSSIL_OMIT_DELTA_CKSUM_TEST
          546  +#if RBU_ENABLE_DELTA_CKSUM
   538    547     char *zOrigOut = zOut;
   539    548   #endif
   540    549   
   541    550     limit = rbuDeltaGetInt(&zDelta, &lenDelta);
   542    551     if( *zDelta!='\n' ){
   543    552       /* ERROR: size integer not terminated by "\n" */
   544    553       return -1;
................................................................................
   585    594           zDelta += cnt;
   586    595           lenDelta -= cnt;
   587    596           break;
   588    597         }
   589    598         case ';': {
   590    599           zDelta++; lenDelta--;
   591    600           zOut[0] = 0;
   592         -#ifndef FOSSIL_OMIT_DELTA_CKSUM_TEST
          601  +#if RBU_ENABLE_DELTA_CKSUM
   593    602           if( cnt!=rbuDeltaChecksum(zOrigOut, total) ){
   594    603             /* ERROR:  bad checksum */
   595    604             return -1;
   596    605           }
   597    606   #endif
   598    607           if( total!=limit ){
   599    608             /* ERROR: generated size does not match predicted size */