From: danielk1977 Date: Thu, 1 Jan 2009 14:06:13 +0000 (+0000) Subject: Fix some problems in the fts3 expression parser with mismatched parenthesis. (CVS... X-Git-Tag: version-3.6.10~89 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fc8c9f84ab3295c5c0e1d43329343d1678bf3bd8;p=thirdparty%2Fsqlite.git Fix some problems in the fts3 expression parser with mismatched parenthesis. (CVS 6095) FossilOrigin-Name: ccfe4580ac7ba9add0e69c786a9a3a43d69b7753 --- diff --git a/ext/fts3/fts3_expr.c b/ext/fts3/fts3_expr.c index b4eb888704..eb4d4f812a 100644 --- a/ext/fts3/fts3_expr.c +++ b/ext/fts3/fts3_expr.c @@ -288,9 +288,9 @@ static int getNextNode( ){ static const struct Fts3Keyword { char z[4]; /* Keyword text */ - u8 n; /* Length of the keyword */ - u8 parenOnly; /* Only valid in paren mode */ - u8 eType; /* Keyword code */ + unsigned char n; /* Length of the keyword */ + unsigned char parenOnly; /* Only valid in paren mode */ + unsigned char eType; /* Keyword code */ } aKeyword[] = { { "OR" , 2, 0, FTSQUERY_OR }, { "AND", 3, 1, FTSQUERY_AND }, @@ -313,6 +313,9 @@ static int getNextNode( nInput--; zInput++; } + if( nInput==0 ){ + return SQLITE_DONE; + } /* See if we are dealing with a keyword. */ for(ii=0; ii<(int)(sizeof(aKeyword)/sizeof(struct Fts3Keyword)); ii++){ @@ -368,6 +371,9 @@ static int getNextNode( int rc; pParse->nNest++; rc = fts3ExprParse(pParse, &zInput[1], nInput-1, ppExpr, &nConsumed); + if( rc==SQLITE_OK && !*ppExpr ){ + rc = SQLITE_DONE; + } *pnConsumed = (zInput - z) + 1 + nConsumed; return rc; } @@ -509,7 +515,7 @@ static int fts3ExprParse( while( rc==SQLITE_OK ){ Fts3Expr *p = 0; - int nByte; + int nByte = 0; rc = getNextNode(pParse, zIn, nIn, &p, &nByte); if( rc==SQLITE_OK ){ int isPhrase; @@ -597,6 +603,7 @@ static int fts3ExprParse( } assert( nByte>0 ); } + assert( rc!=SQLITE_OK || (nByte>0 && nByte<=nIn) ); nIn -= nByte; zIn += nByte; pPrev = p; diff --git a/manifest b/manifest index 0178bd5fe1..ffb9ababc2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Additional\stest\scases\sand\scleanup\sof\sFTS3\sparenthesis\sprocessing.\s(CVS\s6094) -D 2009-01-01T12:34:46 +C Fix\ssome\sproblems\sin\sthe\sfts3\sexpression\sparser\swith\smismatched\sparenthesis.\s(CVS\s6095) +D 2009-01-01T14:06:13 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 77635d0909c2067cee03889a1e04ce910d8fb809 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -55,7 +55,7 @@ F ext/fts3/README.tokenizers 998756696647400de63d5ba60e9655036cb966e9 F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d F ext/fts3/fts3.c 3aa6aef1eadc44606f6ed3c841062735a5210077 F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe -F ext/fts3/fts3_expr.c 9394701f42abfa6abd58f446841aed65963ee1a1 +F ext/fts3/fts3_expr.c 98fe92f6888c306734ed9332a24383dde77c25aa F ext/fts3/fts3_expr.h b5412dcf565c6d90d6a8c22090ceb9ed8c745634 F ext/fts3/fts3_hash.c e15e84d18f8df149ab290029872d4559c4c7c15a F ext/fts3/fts3_hash.h 004b759e1602ff16dfa02fea3ca1c77336ad6798 @@ -368,7 +368,7 @@ F test/fts3b.test b3a25180a633873d37d86e1ccd00ed690d37237a F test/fts3c.test 4c7ef29b37aca3e8ebb6a39b57910caa6506034e F test/fts3d.test d92a47fe8ed59c9e53d2d8e6d2685bb380aadadc F test/fts3e.test 1f6c6ac9cc8b772ca256e6b22aaeed50c9350851 -F test/fts3expr.test d8f8a3caabefe537461e877910c64e3f12239b79 +F test/fts3expr.test 000f05df771e203187ceac49ad21c303c720b783 F test/fts3expr2.test 8501de895a4c0631e7226c9bac055cd49c9f6646 F test/fts3near.test e8a9b4e16c63a795918b334b74d4aec14815bf8b F test/func.test a50f0a4b69ac251debe1dce3ba29da7476dc8c52 @@ -493,7 +493,7 @@ F test/rollback.test 1f70ab4301d8d105d41438a436cad1fc8897f5e5 F test/rowid.test 1c8fc43c60d273e6ea44dfb992db587f3164312c F test/rtree.test b85fd4f0861a40ca366ac195e363be2528dcfadf F test/safety.test b69e2b2dd5d52a3f78e216967086884bbc1a09c6 -F test/savepoint.test 101110d042aa75adc03180a72657169a8130bd6f +F test/savepoint.test 08803877993d11cfbe3bbbaf811822e068a2dd8b F test/savepoint2.test 18f6c75d5c133b93838019df8988b8cdf379d3de F test/savepoint3.test b3c9aa5af3f777ccb8b9e15597c75c93eb5bc369 F test/savepoint4.test fd8850063e3c40565545f5c291e7f79a30591670 @@ -690,7 +690,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e -P 13146b34935d339d7b8379083e024647af07e2c1 -R 02dfd71ec13a04d1ce31f05761dd721d -U drh -Z c17be682ffb102989648d0f6e43f5ed7 +P afac4293000f81410d105a99956605bf7102fa62 +R f564cdb23ce64284d1cd04ffdf2d252b +U danielk1977 +Z 30d6e7707b897d722bc973a70461e5a8 diff --git a/manifest.uuid b/manifest.uuid index 0246051827..099859e0c3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -afac4293000f81410d105a99956605bf7102fa62 \ No newline at end of file +ccfe4580ac7ba9add0e69c786a9a3a43d69b7753 \ No newline at end of file diff --git a/test/fts3expr.test b/test/fts3expr.test index 4a0a811b46..3b6fef8a15 100644 --- a/test/fts3expr.test +++ b/test/fts3expr.test @@ -11,7 +11,7 @@ # This file implements regression tests for SQLite library. The # focus of this script is testing the FTS3 module. # -# $Id: fts3expr.test,v 1.5 2009/01/01 12:34:46 drh Exp $ +# $Id: fts3expr.test,v 1.6 2009/01/01 14:06:13 danielk1977 Exp $ # set testdir [file dirname $argv0] @@ -337,6 +337,19 @@ do_test fts3expr-4.2.1 { do_test fts3expr-4.2.2 { catchsql { SELECT * FROM t1 WHERE t1 MATCH 'example AND (hello OR world' } } {1 {SQL logic error or missing database}} +do_test fts3expr-4.2.3 { + catchsql { SELECT * FROM t1 WHERE t1 MATCH '(hello' } +} {1 {SQL logic error or missing database}} +do_test fts3expr-4.2.4 { + catchsql { SELECT * FROM t1 WHERE t1 MATCH '(' } +} {1 {SQL logic error or missing database}} +do_test fts3expr-4.2.5 { + catchsql { SELECT * FROM t1 WHERE t1 MATCH ')' } +} {1 {SQL logic error or missing database}} + +do_test fts3expr-4.2.6 { + catchsql { SELECT * FROM t1 WHERE t1 MATCH 'example (hello world' } +} {1 {SQL logic error or missing database}} # Unterminated quotation marks: do_test fts3expr-4.3.1 { diff --git a/test/savepoint.test b/test/savepoint.test index 19ff9883c3..126d9746cc 100644 --- a/test/savepoint.test +++ b/test/savepoint.test @@ -9,7 +9,7 @@ # #*********************************************************************** # -# $Id: savepoint.test,v 1.5 2008/12/30 06:24:58 danielk1977 Exp $ +# $Id: savepoint.test,v 1.6 2009/01/01 14:06:13 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -524,7 +524,6 @@ ifcapable auth { set res [catchsql { RELEASE sp1 }] concat $::authdata $res } {SQLITE_SAVEPOINT RELEASE sp1 {} {} 1 {not authorized}} - }