diff options
author | suzhe@chromium.org <suzhe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-02 01:46:36 +0000 |
---|---|---|
committer | suzhe@chromium.org <suzhe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-02 01:46:36 +0000 |
commit | 301babee0cbae6e4657496437e3b3919e9b78be7 (patch) | |
tree | 4ae3ed46e9874b6a1610da3ffb1264689af7e802 /third_party/sqlite | |
parent | 40b54ee81a395943bbb7333df7f7d9f3e9e22986 (diff) | |
download | chromium_src-301babee0cbae6e4657496437e3b3919e9b78be7.zip chromium_src-301babee0cbae6e4657496437e3b3919e9b78be7.tar.gz chromium_src-301babee0cbae6e4657496437e3b3919e9b78be7.tar.bz2 |
Fix issue 15261: Crash in history::TextDatabase::GetTextMatches
The crash in history::TextDatabase::GetTextMatches is caused by unexpected result of tolower() in some locales such as tr_TR.UTF-8. This CL fixes this issue by using following statement to replace tolower():
(ch>='A' && ch<='Z') ? (ch-'A'+'a') : ch
which will always return expected result for ascii characters regardless of current locale.
BUG=15261 Crash in history::TextDatabase::GetTextMatches
TEST=none
Review URL: http://codereview.chromium.org/174387
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25141 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party/sqlite')
-rw-r--r-- | third_party/sqlite/README.chromium | 6 | ||||
-rw-r--r-- | third_party/sqlite/ext/fts1/fts1.c | 2 | ||||
-rw-r--r-- | third_party/sqlite/ext/fts1/fts1_tokenizer1.c | 2 | ||||
-rw-r--r-- | third_party/sqlite/ext/fts1/simple_tokenizer.c | 2 | ||||
-rw-r--r-- | third_party/sqlite/ext/fts2/fts2.c | 2 | ||||
-rw-r--r-- | third_party/sqlite/ext/fts2/fts2_tokenizer1.c | 2 | ||||
-rw-r--r-- | third_party/sqlite/ext/fts3/fts3.c | 2 | ||||
-rw-r--r-- | third_party/sqlite/ext/fts3/fts3_tokenizer1.c | 2 | ||||
-rw-r--r-- | third_party/sqlite/safe-tolower.patch | 97 |
9 files changed, 109 insertions, 8 deletions
diff --git a/third_party/sqlite/README.chromium b/third_party/sqlite/README.chromium index 7daa083..1050a7d 100644 --- a/third_party/sqlite/README.chromium +++ b/third_party/sqlite/README.chromium @@ -68,7 +68,7 @@ Scott Hess <shess@google.com>, December 11, 2007 -------------------------------------------- -As of July 20, 2009, these are our changes from sqlite_vendor: +As of Sep 2, 2009, these are our changes from sqlite_vendor: - fts2.c disables fts2_tokenizer(). - sqlite3Poison() in src/btree.c. @@ -82,6 +82,10 @@ As of July 20, 2009, these are our changes from sqlite_vendor: - Compile warning fixed in func.c (check if this is still needed) - Fixed a typo bug in fts2_icu.c: "strlen(nInput)" (filed upstream as http://www.sqlite.org/cvstrac/tktview?tn=3543) + - Avoid using tolower() in fts code which causes problem in some locales, see: + safe-tolower.patch + http://crbug.com/15261 + http://www.sqlite.org/src/tktview/991789d9f3136a0460dc83a33e815c1aa9757c26 Changes from Chrome: - I marked all changes I made with "evanm", so you can find them with diff --git a/third_party/sqlite/ext/fts1/fts1.c b/third_party/sqlite/ext/fts1/fts1.c index f067c55..c471a97 100644 --- a/third_party/sqlite/ext/fts1/fts1.c +++ b/third_party/sqlite/ext/fts1/fts1.c @@ -208,7 +208,7 @@ static int safe_isspace(char c){ return (c&0x80)==0 ? isspace(c) : 0; } static int safe_tolower(char c){ - return (c&0x80)==0 ? tolower(c) : c; + return (c>='A' && c<='Z') ? (c-'A'+'a') : c; } static int safe_isalnum(char c){ return (c&0x80)==0 ? isalnum(c) : 0; diff --git a/third_party/sqlite/ext/fts1/fts1_tokenizer1.c b/third_party/sqlite/ext/fts1/fts1_tokenizer1.c index f58fba8..90774da 100644 --- a/third_party/sqlite/ext/fts1/fts1_tokenizer1.c +++ b/third_party/sqlite/ext/fts1/fts1_tokenizer1.c @@ -182,7 +182,7 @@ static int simpleNext( ** case-insensitivity. */ unsigned char ch = p[iStartOffset+i]; - c->pToken[i] = ch<0x80 ? tolower(ch) : ch; + c->pToken[i] = (ch>='A' && ch<='Z') ? (ch-'A'+'a') : ch; } *ppToken = c->pToken; *pnBytes = n; diff --git a/third_party/sqlite/ext/fts1/simple_tokenizer.c b/third_party/sqlite/ext/fts1/simple_tokenizer.c index d00a770..9a52bd1 100644 --- a/third_party/sqlite/ext/fts1/simple_tokenizer.c +++ b/third_party/sqlite/ext/fts1/simple_tokenizer.c @@ -138,7 +138,7 @@ static int simpleNext( ** case-insensitivity. */ char ch = c->pCurrent[ii]; - c->zToken[ii] = (unsigned char)ch<0x80 ? tolower(ch) : ch; + c->zToken[ii] = ((ch>='A' && ch<='Z') ? (ch-'A'+'a') : ch); } c->zToken[n] = '\0'; *ppToken = c->zToken; diff --git a/third_party/sqlite/ext/fts2/fts2.c b/third_party/sqlite/ext/fts2/fts2.c index 35ab87c..b261ead 100644 --- a/third_party/sqlite/ext/fts2/fts2.c +++ b/third_party/sqlite/ext/fts2/fts2.c @@ -372,7 +372,7 @@ static int safe_isspace(char c){ return (c&0x80)==0 ? isspace(c) : 0; } static int safe_tolower(char c){ - return (c&0x80)==0 ? tolower(c) : c; + return (c>='A' && c<='Z') ? (c-'A'+'a') : c; } static int safe_isalnum(char c){ return (c&0x80)==0 ? isalnum(c) : 0; diff --git a/third_party/sqlite/ext/fts2/fts2_tokenizer1.c b/third_party/sqlite/ext/fts2/fts2_tokenizer1.c index f2ba49e..1f03cc4 100644 --- a/third_party/sqlite/ext/fts2/fts2_tokenizer1.c +++ b/third_party/sqlite/ext/fts2/fts2_tokenizer1.c @@ -191,7 +191,7 @@ static int simpleNext( ** case-insensitivity. */ unsigned char ch = p[iStartOffset+i]; - c->pToken[i] = ch<0x80 ? tolower(ch) : ch; + c->pToken[i] = (ch>='A' && ch<='Z') ? (ch-'A'+'a') : ch; } *ppToken = c->pToken; *pnBytes = n; diff --git a/third_party/sqlite/ext/fts3/fts3.c b/third_party/sqlite/ext/fts3/fts3.c index cc6dcd8..922cf3f 100644 --- a/third_party/sqlite/ext/fts3/fts3.c +++ b/third_party/sqlite/ext/fts3/fts3.c @@ -330,7 +330,7 @@ static int safe_isspace(char c){ return (c&0x80)==0 ? isspace(c) : 0; } static int safe_tolower(char c){ - return (c&0x80)==0 ? tolower(c) : c; + return (c>='A' && c<='Z') ? (c-'A'+'a') : c; } static int safe_isalnum(char c){ return (c&0x80)==0 ? isalnum(c) : 0; diff --git a/third_party/sqlite/ext/fts3/fts3_tokenizer1.c b/third_party/sqlite/ext/fts3/fts3_tokenizer1.c index da255d9..1df3910 100644 --- a/third_party/sqlite/ext/fts3/fts3_tokenizer1.c +++ b/third_party/sqlite/ext/fts3/fts3_tokenizer1.c @@ -191,7 +191,7 @@ static int simpleNext( ** case-insensitivity. */ unsigned char ch = p[iStartOffset+i]; - c->pToken[i] = ch<0x80 ? tolower(ch) : ch; + c->pToken[i] = (ch>='A' && ch<='Z') ? (ch-'A'+'a') : ch; } *ppToken = c->pToken; *pnBytes = n; diff --git a/third_party/sqlite/safe-tolower.patch b/third_party/sqlite/safe-tolower.patch new file mode 100644 index 0000000..a0ec849 --- /dev/null +++ b/third_party/sqlite/safe-tolower.patch @@ -0,0 +1,97 @@ +This patch removes the usage of tolower() in fts code, which is not locale +neutral and causes problem in some locales such as Turkish. +See http://crbug.com/15261 for details. +An upstream ticket was also created for this issue: +http://www.sqlite.org/src/tktview/991789d9f3136a0460dc83a33e815c1aa9757c26 + +Index: ext/fts3/fts3.c +=================================================================== +--- ext/fts3/fts3.c (revision 24387) ++++ ext/fts3/fts3.c (working copy) +@@ -330,7 +330,7 @@ + return (c&0x80)==0 ? isspace(c) : 0; + } + static int safe_tolower(char c){ +- return (c&0x80)==0 ? tolower(c) : c; ++ return (c>='A' && c<='Z') ? (c-'A'+'a') : c; + } + static int safe_isalnum(char c){ + return (c&0x80)==0 ? isalnum(c) : 0; +Index: ext/fts3/fts3_tokenizer1.c +=================================================================== +--- ext/fts3/fts3_tokenizer1.c (revision 24387) ++++ ext/fts3/fts3_tokenizer1.c (working copy) +@@ -191,7 +191,7 @@ + ** case-insensitivity. + */ + unsigned char ch = p[iStartOffset+i]; +- c->pToken[i] = ch<0x80 ? tolower(ch) : ch; ++ c->pToken[i] = (ch>='A' && ch<='Z') ? (ch-'A'+'a') : ch; + } + *ppToken = c->pToken; + *pnBytes = n; +Index: ext/fts1/simple_tokenizer.c +=================================================================== +--- ext/fts1/simple_tokenizer.c (revision 24387) ++++ ext/fts1/simple_tokenizer.c (working copy) +@@ -138,7 +138,7 @@ + ** case-insensitivity. + */ + char ch = c->pCurrent[ii]; +- c->zToken[ii] = (unsigned char)ch<0x80 ? tolower(ch) : ch; ++ c->zToken[ii] = ((ch>='A' && ch<='Z') ? (ch-'A'+'a') : ch); + } + c->zToken[n] = '\0'; + *ppToken = c->zToken; +Index: ext/fts1/fts1_tokenizer1.c +=================================================================== +--- ext/fts1/fts1_tokenizer1.c (revision 24387) ++++ ext/fts1/fts1_tokenizer1.c (working copy) +@@ -182,7 +182,7 @@ + ** case-insensitivity. + */ + unsigned char ch = p[iStartOffset+i]; +- c->pToken[i] = ch<0x80 ? tolower(ch) : ch; ++ c->pToken[i] = (ch>='A' && ch<='Z') ? (ch-'A'+'a') : ch; + } + *ppToken = c->pToken; + *pnBytes = n; +Index: ext/fts1/fts1.c +=================================================================== +--- ext/fts1/fts1.c (revision 24387) ++++ ext/fts1/fts1.c (working copy) +@@ -208,7 +208,7 @@ + return (c&0x80)==0 ? isspace(c) : 0; + } + static int safe_tolower(char c){ +- return (c&0x80)==0 ? tolower(c) : c; ++ return (c>='A' && c<='Z') ? (c-'A'+'a') : c; + } + static int safe_isalnum(char c){ + return (c&0x80)==0 ? isalnum(c) : 0; +Index: ext/fts2/fts2.c +=================================================================== +--- ext/fts2/fts2.c (revision 24387) ++++ ext/fts2/fts2.c (working copy) +@@ -372,7 +372,7 @@ + return (c&0x80)==0 ? isspace(c) : 0; + } + static int safe_tolower(char c){ +- return (c&0x80)==0 ? tolower(c) : c; ++ return (c>='A' && c<='Z') ? (c-'A'+'a') : c; + } + static int safe_isalnum(char c){ + return (c&0x80)==0 ? isalnum(c) : 0; +Index: ext/fts2/fts2_tokenizer1.c +=================================================================== +--- ext/fts2/fts2_tokenizer1.c (revision 24387) ++++ ext/fts2/fts2_tokenizer1.c (working copy) +@@ -191,7 +191,7 @@ + ** case-insensitivity. + */ + unsigned char ch = p[iStartOffset+i]; +- c->pToken[i] = ch<0x80 ? tolower(ch) : ch; ++ c->pToken[i] = (ch>='A' && ch<='Z') ? (ch-'A'+'a') : ch; + } + *ppToken = c->pToken; + *pnBytes = n; |