/ 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 Unified Diffs Ignore Whitespace Patch

Added ext/ota/ota7.test.







































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# 2014 October 21
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# This file contains tests for the OTA module. Specifically, it tests the
# that affinities are correctly applied to values within the OTA database.
#

if {![info exists testdir]} {
  set testdir [file join [file dirname [info script]] .. .. test]
}
source $testdir/tester.tcl
set ::testprefix ota7

do_test 1.0 {
  execsql {
    CREATE TABLE t1(a INT PRIMARY KEY, b) WITHOUT ROWID;
    INSERT INTO t1 VALUES(1, 'abc');
    INSERT INTO t1 VALUES(2, 'def');
  }

  forcedelete ota.db
  sqlite3 ota ota.db
  ota eval {
    CREATE TABLE data_t1(a, b, ota_control);
    INSERT INTO data_t1 VALUES('1', NULL, 1);
  }
  ota close
} {}

do_test 1.1 {
  sqlite3ota ota test.db ota.db
  while { [ota step]=="SQLITE_OK" } {}
  ota close
} {SQLITE_DONE}

sqlite3 db test.db
do_execsql_test 1.2 {
  SELECT * FROM t1
} {2 def}

finish_test


Changes to src/vdbeblob.c.

606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
      sqlite3VdbeJumpHere(v, addr);
    }

    /* Code the IdxInsert to write to the b-tree index. */
    sqlite3VdbeAddOp2(v, OP_IdxInsert, 0, regRec);
  }else{
    /* Code the IdxDelete to remove the entry from the b-tree index. */
    sqlite3VdbeAddOp4(v, OP_Affinity, 0, pIdx->nColumn, 0, zAffinity, 0);
    sqlite3VdbeAddOp3(v, OP_IdxDelete, 0, 1, pIdx->nColumn);
  }
  sqlite3FinishCoding(pParse);

index_writer_out:
  if( rc==SQLITE_OK && db->mallocFailed==0 ){
    *ppStmt = (sqlite3_stmt*)v;







|







606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
      sqlite3VdbeJumpHere(v, addr);
    }

    /* Code the IdxInsert to write to the b-tree index. */
    sqlite3VdbeAddOp2(v, OP_IdxInsert, 0, regRec);
  }else{
    /* Code the IdxDelete to remove the entry from the b-tree index. */
    sqlite3VdbeAddOp4(v, OP_Affinity, 1, pIdx->nColumn, 0, zAffinity, 0);
    sqlite3VdbeAddOp3(v, OP_IdxDelete, 0, 1, pIdx->nColumn);
  }
  sqlite3FinishCoding(pParse);

index_writer_out:
  if( rc==SQLITE_OK && db->mallocFailed==0 ){
    *ppStmt = (sqlite3_stmt*)v;