/ Check-in [447b33b3]
Login

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

Overview
Comment:Fix a problem with the parameters to an OP_Affinity in one of the VM programs generated by sqlite3_index_writer() that was causing an OOB read.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | ota-update
Files: files | file ages | folders
SHA1: 447b33b34a9836992f5a8d50cd8647a10435c144
User & Date: dan 2014-11-17 15:07:40
Context
2014-11-17
17:57
Changes so that sqlite3_ckpt_open() works with zipvfs databases. check-in: acbed338 user: dan tags: ota-update
15:07
Fix a problem with the parameters to an OP_Affinity in one of the VM programs generated by sqlite3_index_writer() that was causing an OOB read. check-in: 447b33b3 user: dan tags: ota-update
2014-10-22
15:33
Add tests to check error handling in OTA. check-in: ec7321ae user: dan tags: ota-update
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Added ext/ota/ota7.test.

            1  +# 2014 October 21
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#***********************************************************************
           11  +#
           12  +# This file contains tests for the OTA module. Specifically, it tests the
           13  +# that affinities are correctly applied to values within the OTA database.
           14  +#
           15  +
           16  +if {![info exists testdir]} {
           17  +  set testdir [file join [file dirname [info script]] .. .. test]
           18  +}
           19  +source $testdir/tester.tcl
           20  +set ::testprefix ota7
           21  +
           22  +do_test 1.0 {
           23  +  execsql {
           24  +    CREATE TABLE t1(a INT PRIMARY KEY, b) WITHOUT ROWID;
           25  +    INSERT INTO t1 VALUES(1, 'abc');
           26  +    INSERT INTO t1 VALUES(2, 'def');
           27  +  }
           28  +
           29  +  forcedelete ota.db
           30  +  sqlite3 ota ota.db
           31  +  ota eval {
           32  +    CREATE TABLE data_t1(a, b, ota_control);
           33  +    INSERT INTO data_t1 VALUES('1', NULL, 1);
           34  +  }
           35  +  ota close
           36  +} {}
           37  +
           38  +do_test 1.1 {
           39  +  sqlite3ota ota test.db ota.db
           40  +  while { [ota step]=="SQLITE_OK" } {}
           41  +  ota close
           42  +} {SQLITE_DONE}
           43  +
           44  +sqlite3 db test.db
           45  +do_execsql_test 1.2 {
           46  +  SELECT * FROM t1
           47  +} {2 def}
           48  +
           49  +finish_test
           50  +
           51  +

Changes to src/vdbeblob.c.

   606    606         sqlite3VdbeJumpHere(v, addr);
   607    607       }
   608    608   
   609    609       /* Code the IdxInsert to write to the b-tree index. */
   610    610       sqlite3VdbeAddOp2(v, OP_IdxInsert, 0, regRec);
   611    611     }else{
   612    612       /* Code the IdxDelete to remove the entry from the b-tree index. */
   613         -    sqlite3VdbeAddOp4(v, OP_Affinity, 0, pIdx->nColumn, 0, zAffinity, 0);
          613  +    sqlite3VdbeAddOp4(v, OP_Affinity, 1, pIdx->nColumn, 0, zAffinity, 0);
   614    614       sqlite3VdbeAddOp3(v, OP_IdxDelete, 0, 1, pIdx->nColumn);
   615    615     }
   616    616     sqlite3FinishCoding(pParse);
   617    617   
   618    618   index_writer_out:
   619    619     if( rc==SQLITE_OK && db->mallocFailed==0 ){
   620    620       *ppStmt = (sqlite3_stmt*)v;