diff options
author | drh <drh@noemail.net> | 2012-03-20 03:10:51 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2012-03-20 03:10:51 +0000 |
commit | 82ebc2a098bbe4cb66e18b50d65802f6263a41f1 (patch) | |
tree | e8bef27eab19a3fc2f024d0f0932880dfd20b64c /src | |
parent | 0299b40f0fa6ae9de1af5dd1c15cb64fc7797a1a (diff) | |
download | sqlite-82ebc2a098bbe4cb66e18b50d65802f6263a41f1.tar.gz sqlite-82ebc2a098bbe4cb66e18b50d65802f6263a41f1.zip |
Fix out-of-bounds array references in the "echo" virtual table module
used for testing. No changes to the SQLite core.
FossilOrigin-Name: 7b449b301ea03295262b8d572b02625e4b39cfa5
Diffstat (limited to 'src')
-rw-r--r-- | src/test8.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/test8.c b/src/test8.c index 283d790b7..80e7adaf2 100644 --- a/src/test8.c +++ b/src/test8.c @@ -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; |