1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-10 01:02:56 +03:00

Fix out-of-bounds array references in the "echo" virtual table module

used for testing.  No changes to the SQLite core.

FossilOrigin-Name: 7b449b301ea03295262b8d572b02625e4b39cfa5
This commit is contained in:
drh
2012-03-20 03:10:51 +00:00
parent 0299b40f0f
commit 82ebc2a098
3 changed files with 13 additions and 17 deletions

View File

@@ -1,5 +1,5 @@
C Add\sadditional\stest\scases\sto\se_insert.test.\s\sUpdate\sevidence\smarks.\nno\schanges\sto\score\scode.
D 2012-03-19T17:42:46.646
C Fix\sout-of-bounds\sarray\sreferences\sin\sthe\s"echo"\svirtual\stable\smodule\nused\sfor\stesting.\s\sNo\schanges\sto\sthe\sSQLite\score.
D 2012-03-20T03:10:51.841
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -196,7 +196,7 @@ F src/test4.c d1e5a5e904d4b444cf572391fdcb017638e36ff7
F src/test5.c a6d1ac55ac054d0b2b8f37b5e655b6c92645a013
F src/test6.c 846ed1ed2f470de9b1e205fe3878a12e237b3e19
F src/test7.c 2e0781754905c8adc3268d8f0967e7633af58843
F src/test8.c 99f70341d6ec480313775127f4cd14b4a47db557
F src/test8.c 61b41d79509a479dec1ac32b6d4209b27c4b1ba5
F src/test9.c bea1e8cf52aa93695487badedd6e1886c321ea60
F src/test_async.c 0612a752896fad42d55c3999a5122af10dcf22ad
F src/test_autoext.c 30e7bd98ab6d70a62bb9ba572e4c7df347fe645e
@@ -992,7 +992,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
P bc03d99a78e90c02b69037e5f5f81537b5a3ac60
R 69afcc9757d71d53b13c043daaf0c06c
P 036395c0a8e08883b11df025e3da9e2461e4b1eb
R 4ef201d6122aecff56466ef062fb4020
U drh
Z e41b3b1650d5b16145f025deed2994e7
Z 262756c9236d4e1eee4ee8920cc99860

View File

@@ -1 +1 @@
036395c0a8e08883b11df025e3da9e2461e4b1eb
7b449b301ea03295262b8d572b02625e4b39cfa5

View File

@@ -831,13 +831,10 @@ static int echoBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
if( !isIgnoreUsable && !pConstraint->usable ) continue;
iCol = pConstraint->iColumn;
if( pVtab->aIndex[iCol] || iCol<0 ){
char *zCol = pVtab->aCol[iCol];
if( iCol<0 || pVtab->aIndex[iCol] ){
char *zCol = iCol>=0 ? pVtab->aCol[iCol] : "rowid";
char *zOp = 0;
useIdx = 1;
if( iCol<0 ){
zCol = "rowid";
}
switch( pConstraint->op ){
case SQLITE_INDEX_CONSTRAINT_EQ:
zOp = "="; break;
@@ -870,13 +867,12 @@ static int echoBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
** on a column that this virtual table has an index for, then consume
** the ORDER BY clause.
*/
if( pIdxInfo->nOrderBy==1 && pVtab->aIndex[pIdxInfo->aOrderBy->iColumn] ){
if( pIdxInfo->nOrderBy==1 && (
pIdxInfo->aOrderBy->iColumn<0 ||
pVtab->aIndex[pIdxInfo->aOrderBy->iColumn]) ){
int iCol = pIdxInfo->aOrderBy->iColumn;
char *zCol = pVtab->aCol[iCol];
char *zCol = iCol>=0 ? pVtab->aCol[iCol] : "rowid";
char *zDir = pIdxInfo->aOrderBy->desc?"DESC":"ASC";
if( iCol<0 ){
zCol = "rowid";
}
zNew = sqlite3_mprintf(" ORDER BY %s %s", zCol, zDir);
string_concat(&zQuery, zNew, 1, &rc);
pIdxInfo->orderByConsumed = 1;