diff options
author | dan <dan@noemail.net> | 2019-01-18 19:26:48 +0000 |
---|---|---|
committer | dan <dan@noemail.net> | 2019-01-18 19:26:48 +0000 |
commit | 451297752c90784f42e5d16b6ccd816fce4a3139 (patch) | |
tree | 94c239486afe5bf4917546727300db67d0dd3913 /ext/fts3/fts3_snippet.c | |
parent | ed968fa4cb464906e5b0f5148f1f21038a311728 (diff) | |
download | sqlite-451297752c90784f42e5d16b6ccd816fce4a3139.tar.gz sqlite-451297752c90784f42e5d16b6ccd816fce4a3139.zip |
Fix problems causing undefined left-shift operations in the fts3 snippet()
function.
FossilOrigin-Name: b90dbaed3092236e97f9796fa63989a3648060e16189e1267c430f4a7e799fac
Diffstat (limited to 'ext/fts3/fts3_snippet.c')
-rw-r--r-- | ext/fts3/fts3_snippet.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/ext/fts3/fts3_snippet.c b/ext/fts3/fts3_snippet.c index 4ab60c1d8..58419536a 100644 --- a/ext/fts3/fts3_snippet.c +++ b/ext/fts3/fts3_snippet.c @@ -433,7 +433,8 @@ static void fts3SnippetDetails( int j; u64 mPhrase = (u64)1 << i; u64 mPos = (u64)1 << (iCsr - iStart); - assert( iCsr>=iStart ); + assert( iCsr>=iStart && (iCsr - iStart)<=64 ); + assert( i>=0 && i<=64 ); if( (mCover|mCovered)&mPhrase ){ iScore++; }else{ @@ -660,6 +661,7 @@ static int fts3SnippetShift( for(nLeft=0; !(hlmask & ((u64)1 << nLeft)); nLeft++); for(nRight=0; !(hlmask & ((u64)1 << (nSnippet-1-nRight))); nRight++); + assert( (nSnippet-1-nRight)<=63 && (nSnippet-1-nRight)>=0 ); nDesired = (nLeft-nRight)/2; /* Ideally, the start of the snippet should be pushed forward in the @@ -1433,6 +1435,10 @@ void sqlite3Fts3Snippet( return; } + /* Limit the snippet length to 64 tokens. */ + if( nToken<-64 ) nToken = -64; + if( nToken>+64 ) nToken = +64; + for(nSnippet=1; 1; nSnippet++){ int iSnip; /* Loop counter 0..nSnippet-1 */ |