summaryrefslogtreecommitdiffstats
path: root/third_party/sqlite
diff options
context:
space:
mode:
authorshess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-10 02:52:43 +0000
committershess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-10 02:52:43 +0000
commitc8893e02045b5cc858be8c6e20426ca64272d779 (patch)
tree3fcba3af6c57c23e59d86e9938e206b132c48c20 /third_party/sqlite
parent8e38c9db2f2720c9e1fcc20dca0f6829b796989d (diff)
downloadchromium_src-c8893e02045b5cc858be8c6e20426ca64272d779.zip
chromium_src-c8893e02045b5cc858be8c6e20426ca64272d779.tar.gz
chromium_src-c8893e02045b5cc858be8c6e20426ca64272d779.tar.bz2
Backport SQLite memcmp patch.
http://www.sqlite.org/src/info/d73435587b Verified that the amalgamation came out with all the right patches by comparing the amalgamation diff to the appropriately-ordered diffs of the original files. BUG=178677 Review URL: https://chromiumcodereview.appspot.com/15070002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@199345 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party/sqlite')
-rw-r--r--third_party/sqlite/README.chromium2
-rw-r--r--third_party/sqlite/amalgamation/sqlite3.c14
-rw-r--r--third_party/sqlite/memcmp.patch87
-rw-r--r--third_party/sqlite/src/src/analyze.c4
-rw-r--r--third_party/sqlite/src/src/build.c2
-rw-r--r--third_party/sqlite/src/src/expr.c4
-rw-r--r--third_party/sqlite/src/src/os_unix.c2
-rw-r--r--third_party/sqlite/src/src/vdbeapi.c2
8 files changed, 101 insertions, 16 deletions
diff --git a/third_party/sqlite/README.chromium b/third_party/sqlite/README.chromium
index c502d47b..d129d62 100644
--- a/third_party/sqlite/README.chromium
+++ b/third_party/sqlite/README.chromium
@@ -89,6 +89,7 @@ patch -p0 < ../sqlite/mac_time_machine.patch
patch -p0 < ../sqlite/system-sqlite.patch
patch -p0 < ../sqlite/sqlite-3.7.6.3-fix-out-of-scope-memory-reference.patch
patch -p0 < ../sqlite/misalignment.patch
+patch -p0 < ../sqlite/memcmp.patch
This will only be the case if all changes we make also update the corresponding
patch files. Therefore please remember to do that whenever you make a change!
@@ -196,3 +197,4 @@ Changes from Chrome:
- src/recover.c file implements a virtual table which can read
through corruption.
- Enable the macro 'SQLITE_TEMP_STORE=3' for Android.
+ - memcmp.patch backports ASAN-related fixes from SQLite trunk.
diff --git a/third_party/sqlite/amalgamation/sqlite3.c b/third_party/sqlite/amalgamation/sqlite3.c
index b9088a5..247d842 100644
--- a/third_party/sqlite/amalgamation/sqlite3.c
+++ b/third_party/sqlite/amalgamation/sqlite3.c
@@ -28651,7 +28651,7 @@ int fillInUnixFile(
OSTRACE(("OPEN %-3d %s\n", h, zFilename));
pNew->h = h;
pNew->zPath = zFilename;
- if( memcmp(pVfs->zName,"unix-excl",10)==0 ){
+ if( strcmp(pVfs->zName,"unix-excl")==0 ){
pNew->ctrlFlags = UNIXFILE_EXCL;
}else{
pNew->ctrlFlags = 0;
@@ -61676,7 +61676,7 @@ SQLITE_PRIVATE int sqlite3VdbeParameterIndex(Vdbe *p, const char *zName, int nNa
if( zName ){
for(i=0; i<p->nVar; i++){
const char *z = p->azVar[i];
- if( z && memcmp(z,zName,nName)==0 && z[nName]==0 ){
+ if( z && strncmp(z,zName,nName)==0 && z[nName]==0 ){
return i+1;
}
}
@@ -71435,12 +71435,10 @@ SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr){
** has never appeared before, reuse the same variable number
*/
int i;
- u32 n;
- n = sqlite3Strlen30(z);
for(i=0; i<pParse->nVarExpr; i++){
Expr *pE = pParse->apVarExpr[i];
assert( pE!=0 );
- if( memcmp(pE->u.zToken, z, n)==0 && pE->u.zToken[n]==0 ){
+ if( strcmp(pE->u.zToken, z)==0 ){
pExpr->iColumn = pE->iColumn;
break;
}
@@ -75586,7 +75584,7 @@ static void analyzeOneTable(
/* Do not gather statistics on views or virtual tables */
return;
}
- if( memcmp(pTab->zName, "sqlite_", 7)==0 ){
+ if( sqlite3_strnicmp(pTab->zName, "sqlite_", 7)==0 ){
/* Do not gather statistics on system tables */
return;
}
@@ -75992,7 +75990,7 @@ static int analysisLoader(void *pData, int argc, char **argv, char **NotUsed){
if( pIndex==0 ) break;
pIndex->aiRowEst[i] = v;
if( *z==' ' ) z++;
- if( memcmp(z, "unordered", 10)==0 ){
+ if( strcmp(z, "unordered")==0 ){
pIndex->bUnordered = 1;
break;
}
@@ -79439,7 +79437,7 @@ SQLITE_PRIVATE Index *sqlite3CreateIndex(
assert( pTab!=0 );
assert( pParse->nErr==0 );
if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0
- && memcmp(&pTab->zName[7],"altertab_",9)!=0 ){
+ && sqlite3StrNICmp(&pTab->zName[7],"altertab_",9)!=0 ){
sqlite3ErrorMsg(pParse, "table %s may not be indexed", pTab->zName);
goto exit_create_index;
}
diff --git a/third_party/sqlite/memcmp.patch b/third_party/sqlite/memcmp.patch
new file mode 100644
index 0000000..ff562e8
--- /dev/null
+++ b/third_party/sqlite/memcmp.patch
@@ -0,0 +1,87 @@
+http://crbug.com/178677 refers to potential buffer overruns in ASAN
+due to memcmp() being used instead of strcmp() in SQLite. Reported to
+SQLite team, resulting in http://www.sqlite.org/src/info/d73435587b .
+This was backported into Chromium's version of SQLite, then this file
+was generated using:
+ git diff --relative=third_party/sqlite/src --src-prefix='' --dst-prefix='' > third_party/sqlite/memcmp.patch
+
+
+diff --git src/analyze.c src/analyze.c
+index 17c1de8..2444e74 100644
+--- src/analyze.c
++++ src/analyze.c
+@@ -142,7 +142,7 @@ static void analyzeOneTable(
+ /* Do not gather statistics on views or virtual tables */
+ return;
+ }
+- if( memcmp(pTab->zName, "sqlite_", 7)==0 ){
++ if( sqlite3_strnicmp(pTab->zName, "sqlite_", 7)==0 ){
+ /* Do not gather statistics on system tables */
+ return;
+ }
+@@ -548,7 +548,7 @@ static int analysisLoader(void *pData, int argc, char **argv, char **NotUsed){
+ if( pIndex==0 ) break;
+ pIndex->aiRowEst[i] = v;
+ if( *z==' ' ) z++;
+- if( memcmp(z, "unordered", 10)==0 ){
++ if( strcmp(z, "unordered")==0 ){
+ pIndex->bUnordered = 1;
+ break;
+ }
+diff --git src/build.c src/build.c
+index 323a616..4f4f8ed 100644
+--- src/build.c
++++ src/build.c
+@@ -2480,7 +2480,7 @@ Index *sqlite3CreateIndex(
+ assert( pTab!=0 );
+ assert( pParse->nErr==0 );
+ if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0
+- && memcmp(&pTab->zName[7],"altertab_",9)!=0 ){
++ && sqlite3StrNICmp(&pTab->zName[7],"altertab_",9)!=0 ){
+ sqlite3ErrorMsg(pParse, "table %s may not be indexed", pTab->zName);
+ goto exit_create_index;
+ }
+diff --git src/expr.c src/expr.c
+index 2699ae1..9d1193b 100644
+--- src/expr.c
++++ src/expr.c
+@@ -578,12 +578,10 @@ void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr){
+ ** has never appeared before, reuse the same variable number
+ */
+ int i;
+- u32 n;
+- n = sqlite3Strlen30(z);
+ for(i=0; i<pParse->nVarExpr; i++){
+ Expr *pE = pParse->apVarExpr[i];
+ assert( pE!=0 );
+- if( memcmp(pE->u.zToken, z, n)==0 && pE->u.zToken[n]==0 ){
++ if( strcmp(pE->u.zToken, z)==0 ){
+ pExpr->iColumn = pE->iColumn;
+ break;
+ }
+diff --git src/os_unix.c src/os_unix.c
+index 804c588..77ffd8a 100644
+--- src/os_unix.c
++++ src/os_unix.c
+@@ -4506,7 +4506,7 @@ int fillInUnixFile(
+ OSTRACE(("OPEN %-3d %s\n", h, zFilename));
+ pNew->h = h;
+ pNew->zPath = zFilename;
+- if( memcmp(pVfs->zName,"unix-excl",10)==0 ){
++ if( strcmp(pVfs->zName,"unix-excl")==0 ){
+ pNew->ctrlFlags = UNIXFILE_EXCL;
+ }else{
+ pNew->ctrlFlags = 0;
+diff --git src/vdbeapi.c src/vdbeapi.c
+index 90baacc..80ceb9f 100644
+--- src/vdbeapi.c
++++ src/vdbeapi.c
+@@ -1222,7 +1222,7 @@ int sqlite3VdbeParameterIndex(Vdbe *p, const char *zName, int nName){
+ if( zName ){
+ for(i=0; i<p->nVar; i++){
+ const char *z = p->azVar[i];
+- if( z && memcmp(z,zName,nName)==0 && z[nName]==0 ){
++ if( z && strncmp(z,zName,nName)==0 && z[nName]==0 ){
+ return i+1;
+ }
+ }
diff --git a/third_party/sqlite/src/src/analyze.c b/third_party/sqlite/src/src/analyze.c
index 17c1de8..2444e74 100644
--- a/third_party/sqlite/src/src/analyze.c
+++ b/third_party/sqlite/src/src/analyze.c
@@ -142,7 +142,7 @@ static void analyzeOneTable(
/* Do not gather statistics on views or virtual tables */
return;
}
- if( memcmp(pTab->zName, "sqlite_", 7)==0 ){
+ if( sqlite3_strnicmp(pTab->zName, "sqlite_", 7)==0 ){
/* Do not gather statistics on system tables */
return;
}
@@ -548,7 +548,7 @@ static int analysisLoader(void *pData, int argc, char **argv, char **NotUsed){
if( pIndex==0 ) break;
pIndex->aiRowEst[i] = v;
if( *z==' ' ) z++;
- if( memcmp(z, "unordered", 10)==0 ){
+ if( strcmp(z, "unordered")==0 ){
pIndex->bUnordered = 1;
break;
}
diff --git a/third_party/sqlite/src/src/build.c b/third_party/sqlite/src/src/build.c
index 323a616..4f4f8ed 100644
--- a/third_party/sqlite/src/src/build.c
+++ b/third_party/sqlite/src/src/build.c
@@ -2480,7 +2480,7 @@ Index *sqlite3CreateIndex(
assert( pTab!=0 );
assert( pParse->nErr==0 );
if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0
- && memcmp(&pTab->zName[7],"altertab_",9)!=0 ){
+ && sqlite3StrNICmp(&pTab->zName[7],"altertab_",9)!=0 ){
sqlite3ErrorMsg(pParse, "table %s may not be indexed", pTab->zName);
goto exit_create_index;
}
diff --git a/third_party/sqlite/src/src/expr.c b/third_party/sqlite/src/src/expr.c
index 2699ae1..9d1193b 100644
--- a/third_party/sqlite/src/src/expr.c
+++ b/third_party/sqlite/src/src/expr.c
@@ -578,12 +578,10 @@ void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr){
** has never appeared before, reuse the same variable number
*/
int i;
- u32 n;
- n = sqlite3Strlen30(z);
for(i=0; i<pParse->nVarExpr; i++){
Expr *pE = pParse->apVarExpr[i];
assert( pE!=0 );
- if( memcmp(pE->u.zToken, z, n)==0 && pE->u.zToken[n]==0 ){
+ if( strcmp(pE->u.zToken, z)==0 ){
pExpr->iColumn = pE->iColumn;
break;
}
diff --git a/third_party/sqlite/src/src/os_unix.c b/third_party/sqlite/src/src/os_unix.c
index 804c588..77ffd8a 100644
--- a/third_party/sqlite/src/src/os_unix.c
+++ b/third_party/sqlite/src/src/os_unix.c
@@ -4506,7 +4506,7 @@ int fillInUnixFile(
OSTRACE(("OPEN %-3d %s\n", h, zFilename));
pNew->h = h;
pNew->zPath = zFilename;
- if( memcmp(pVfs->zName,"unix-excl",10)==0 ){
+ if( strcmp(pVfs->zName,"unix-excl")==0 ){
pNew->ctrlFlags = UNIXFILE_EXCL;
}else{
pNew->ctrlFlags = 0;
diff --git a/third_party/sqlite/src/src/vdbeapi.c b/third_party/sqlite/src/src/vdbeapi.c
index 90baacc..80ceb9f 100644
--- a/third_party/sqlite/src/src/vdbeapi.c
+++ b/third_party/sqlite/src/src/vdbeapi.c
@@ -1222,7 +1222,7 @@ int sqlite3VdbeParameterIndex(Vdbe *p, const char *zName, int nName){
if( zName ){
for(i=0; i<p->nVar; i++){
const char *z = p->azVar[i];
- if( z && memcmp(z,zName,nName)==0 && z[nName]==0 ){
+ if( z && strncmp(z,zName,nName)==0 && z[nName]==0 ){
return i+1;
}
}