From 1439a1e80f924e5bd7484f95fb1bab0a5ec2252a Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 6 Jan 2017 11:55:03 +0000 Subject: [PATCH] Improve handling of corrupt data in fts5. FossilOrigin-Name: 609ac1c73f7c2b48a571c178a72383996a9538fe --- ext/fts5/fts5_index.c | 7 ++++--- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index 46517e1aeb..750e0ca82d 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -2039,7 +2039,7 @@ static void fts5SegIterNext( else if( pLeaf->nn>pLeaf->szLeaf ){ pIter->iPgidxOff = pLeaf->szLeaf + fts5GetVarint32( &pLeaf->p[pLeaf->szLeaf], iOff - ); + ); pIter->iLeafOffset = iOff; pIter->iEndofDoclist = iOff; bNewTerm = 1; @@ -2073,6 +2073,7 @@ static void fts5SegIterNext( */ int nSz; assert( p->rc==SQLITE_OK ); + assert( pIter->iLeafOffset<=pIter->pLeaf->nn ); fts5FastGetVarint32(pIter->pLeaf->p, pIter->iLeafOffset, nSz); pIter->bDel = (nSz & 0x0001); pIter->nPos = nSz>>1; @@ -3067,7 +3068,7 @@ static void fts5ChunkIterate( break; }else{ pgno++; - pData = fts5DataRead(p, FTS5_SEGMENT_ROWID(pSeg->pSeg->iSegid, pgno)); + pData = fts5LeafRead(p, FTS5_SEGMENT_ROWID(pSeg->pSeg->iSegid, pgno)); if( pData==0 ) break; pChunk = &pData->p[4]; nChunk = MIN(nRem, pData->szLeaf - 4); @@ -5829,7 +5830,7 @@ static void fts5IndexIntegrityCheckSegment( ** ignore this b-tree entry. Otherwise, load it into memory. */ if( iIdxLeafpgnoFirst ) continue; iRow = FTS5_SEGMENT_ROWID(pSeg->iSegid, iIdxLeaf); - pLeaf = fts5DataRead(p, iRow); + pLeaf = fts5LeafRead(p, iRow); if( pLeaf==0 ) break; /* Check that the leaf contains at least one term, and that it is equal diff --git a/manifest b/manifest index 76c54f19bf..2c3a5de518 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Clarify\sthe\sdocumentation\son\ssqlite3_column_count(). -D 2017-01-06T01:09:43.612 +C Improve\shandling\sof\scorrupt\sdata\sin\sfts5. +D 2017-01-06T11:55:03.576 F Makefile.in 41bd4cad981487345c4a84081074bcdb876e4b2e F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da @@ -104,7 +104,7 @@ F ext/fts5/fts5_buffer.c 4c1502d4c956cd092c89ce4480867f9d8bf325cd F ext/fts5/fts5_config.c 5af9c360e99669d29f06492c370892394aba0857 F ext/fts5/fts5_expr.c dc2cee9f56b1818b85df59304b8104a5dfb8ab60 F ext/fts5/fts5_hash.c 880998e596b60f078348d48732ca4ad9a90caad2 -F ext/fts5/fts5_index.c fdbe46da11e81c1817cd4cb2de25ffdb4dd83711 +F ext/fts5/fts5_index.c f67032a9a529ba52a545e6e3ab970764199c05d4 F ext/fts5/fts5_main.c f85281445dcf8be32d18841c93a6f90fe27dbfe2 F ext/fts5/fts5_storage.c de0ed8a06738bde433afe11e92295ceaffbc4e58 F ext/fts5/fts5_tcl.c 4a901f00c8553740dba63511603f5527d741c26a @@ -1543,7 +1543,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 28d87789141d816e0bce6d3965ce84c79b803218 -R e3a76d24c91b951960fc78f33b2e8a32 -U drh -Z 1cf489d9fb6392442bdd62aaa6400c28 +P 9ea0baddd893e54ec79399ae83033ae139650535 +R 44d29edf796e0dea15e29c7ababbe2c4 +U dan +Z 2fd88d4ddce12153e4aca3cee686cd44 diff --git a/manifest.uuid b/manifest.uuid index 1c75ad6a44..e770ae0a32 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9ea0baddd893e54ec79399ae83033ae139650535 \ No newline at end of file +609ac1c73f7c2b48a571c178a72383996a9538fe \ No newline at end of file -- 2.47.2