| OLD | NEW |
| 1 http://crbug.com/178677 refers to potential buffer overruns in ASAN | 1 From cd23f4b26a4575353589a97f039accb2c8ec5143 Mon Sep 17 00:00:00 2001 |
| 2 due to memcmp() being used instead of strcmp() in SQLite. Reported to | 2 From: Scott Hess <shess@chromium.org> |
| 3 SQLite team, resulting in http://www.sqlite.org/src/info/d73435587b . | 3 Date: Fri, 10 May 2013 02:52:43 +0000 |
| 4 This was backported into Chromium's version of SQLite, then this file | 4 Subject: [PATCH 03/23] [backport] SQLite memcmp patch. |
| 5 was generated using: | |
| 6 git diff --relative=third_party/sqlite/src --src-prefix='' --dst-prefix='' > t
hird_party/sqlite/memcmp.patch | |
| 7 | 5 |
| 6 http://www.sqlite.org/src/info/d73435587b |
| 8 | 7 |
| 9 diff --git src/analyze.c src/analyze.c | 8 Verified that the amalgamation came out with all the right patches by |
| 9 comparing the amalgamation diff to the appropriately-ordered diffs of |
| 10 the original files. |
| 11 |
| 12 BUG=178677 |
| 13 |
| 14 Original review URL: https://chromiumcodereview.appspot.com/15070002 |
| 15 --- |
| 16 third_party/sqlite/src/src/analyze.c | 4 ++-- |
| 17 third_party/sqlite/src/src/build.c | 2 +- |
| 18 third_party/sqlite/src/src/expr.c | 4 +--- |
| 19 third_party/sqlite/src/src/os_unix.c | 2 +- |
| 20 third_party/sqlite/src/src/vdbeapi.c | 2 +- |
| 21 5 files changed, 6 insertions(+), 8 deletions(-) |
| 22 |
| 23 diff --git a/third_party/sqlite/src/src/analyze.c b/third_party/sqlite/src/src/a
nalyze.c |
| 10 index 17c1de8..2444e74 100644 | 24 index 17c1de8..2444e74 100644 |
| 11 --- src/analyze.c | 25 --- a/third_party/sqlite/src/src/analyze.c |
| 12 +++ src/analyze.c | 26 +++ b/third_party/sqlite/src/src/analyze.c |
| 13 @@ -142,7 +142,7 @@ static void analyzeOneTable( | 27 @@ -142,7 +142,7 @@ static void analyzeOneTable( |
| 14 /* Do not gather statistics on views or virtual tables */ | 28 /* Do not gather statistics on views or virtual tables */ |
| 15 return; | 29 return; |
| 16 } | 30 } |
| 17 - if( memcmp(pTab->zName, "sqlite_", 7)==0 ){ | 31 - if( memcmp(pTab->zName, "sqlite_", 7)==0 ){ |
| 18 + if( sqlite3_strnicmp(pTab->zName, "sqlite_", 7)==0 ){ | 32 + if( sqlite3_strnicmp(pTab->zName, "sqlite_", 7)==0 ){ |
| 19 /* Do not gather statistics on system tables */ | 33 /* Do not gather statistics on system tables */ |
| 20 return; | 34 return; |
| 21 } | 35 } |
| 22 @@ -548,7 +548,7 @@ static int analysisLoader(void *pData, int argc, char **argv
, char **NotUsed){ | 36 @@ -548,7 +548,7 @@ static int analysisLoader(void *pData, int argc, char **argv
, char **NotUsed){ |
| 23 if( pIndex==0 ) break; | 37 if( pIndex==0 ) break; |
| 24 pIndex->aiRowEst[i] = v; | 38 pIndex->aiRowEst[i] = v; |
| 25 if( *z==' ' ) z++; | 39 if( *z==' ' ) z++; |
| 26 - if( memcmp(z, "unordered", 10)==0 ){ | 40 - if( memcmp(z, "unordered", 10)==0 ){ |
| 27 + if( strcmp(z, "unordered")==0 ){ | 41 + if( strcmp(z, "unordered")==0 ){ |
| 28 pIndex->bUnordered = 1; | 42 pIndex->bUnordered = 1; |
| 29 break; | 43 break; |
| 30 } | 44 } |
| 31 diff --git src/build.c src/build.c | 45 diff --git a/third_party/sqlite/src/src/build.c b/third_party/sqlite/src/src/bui
ld.c |
| 32 index 323a616..4f4f8ed 100644 | 46 index 83a1db8..25a74ca 100644 |
| 33 --- src/build.c | 47 --- a/third_party/sqlite/src/src/build.c |
| 34 +++ src/build.c | 48 +++ b/third_party/sqlite/src/src/build.c |
| 35 @@ -2480,7 +2480,7 @@ Index *sqlite3CreateIndex( | 49 @@ -2477,7 +2477,7 @@ Index *sqlite3CreateIndex( |
| 36 assert( pTab!=0 ); | 50 assert( pTab!=0 ); |
| 37 assert( pParse->nErr==0 ); | 51 assert( pParse->nErr==0 ); |
| 38 if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0 | 52 if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0 |
| 39 - && memcmp(&pTab->zName[7],"altertab_",9)!=0 ){ | 53 - && memcmp(&pTab->zName[7],"altertab_",9)!=0 ){ |
| 40 + && sqlite3StrNICmp(&pTab->zName[7],"altertab_",9)!=0 ){ | 54 + && sqlite3StrNICmp(&pTab->zName[7],"altertab_",9)!=0 ){ |
| 41 sqlite3ErrorMsg(pParse, "table %s may not be indexed", pTab->zName); | 55 sqlite3ErrorMsg(pParse, "table %s may not be indexed", pTab->zName); |
| 42 goto exit_create_index; | 56 goto exit_create_index; |
| 43 } | 57 } |
| 44 diff --git src/expr.c src/expr.c | 58 diff --git a/third_party/sqlite/src/src/expr.c b/third_party/sqlite/src/src/expr
.c |
| 45 index 2699ae1..9d1193b 100644 | 59 index 2699ae1..9d1193b 100644 |
| 46 --- src/expr.c | 60 --- a/third_party/sqlite/src/src/expr.c |
| 47 +++ src/expr.c | 61 +++ b/third_party/sqlite/src/src/expr.c |
| 48 @@ -578,12 +578,10 @@ void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr
){ | 62 @@ -578,12 +578,10 @@ void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr
){ |
| 49 ** has never appeared before, reuse the same variable number | 63 ** has never appeared before, reuse the same variable number |
| 50 */ | 64 */ |
| 51 int i; | 65 int i; |
| 52 - u32 n; | 66 - u32 n; |
| 53 - n = sqlite3Strlen30(z); | 67 - n = sqlite3Strlen30(z); |
| 54 for(i=0; i<pParse->nVarExpr; i++){ | 68 for(i=0; i<pParse->nVarExpr; i++){ |
| 55 Expr *pE = pParse->apVarExpr[i]; | 69 Expr *pE = pParse->apVarExpr[i]; |
| 56 assert( pE!=0 ); | 70 assert( pE!=0 ); |
| 57 - if( memcmp(pE->u.zToken, z, n)==0 && pE->u.zToken[n]==0 ){ | 71 - if( memcmp(pE->u.zToken, z, n)==0 && pE->u.zToken[n]==0 ){ |
| 58 + if( strcmp(pE->u.zToken, z)==0 ){ | 72 + if( strcmp(pE->u.zToken, z)==0 ){ |
| 59 pExpr->iColumn = pE->iColumn; | 73 pExpr->iColumn = pE->iColumn; |
| 60 break; | 74 break; |
| 61 } | 75 } |
| 62 diff --git src/os_unix.c src/os_unix.c | 76 diff --git a/third_party/sqlite/src/src/os_unix.c b/third_party/sqlite/src/src/o
s_unix.c |
| 63 index 804c588..77ffd8a 100644 | 77 index 2626ab4..998e353 100644 |
| 64 --- src/os_unix.c | 78 --- a/third_party/sqlite/src/src/os_unix.c |
| 65 +++ src/os_unix.c | 79 +++ b/third_party/sqlite/src/src/os_unix.c |
| 66 @@ -4506,7 +4506,7 @@ int fillInUnixFile( | 80 @@ -4456,7 +4456,7 @@ static int fillInUnixFile( |
| 67 OSTRACE(("OPEN %-3d %s\n", h, zFilename)); | |
| 68 pNew->h = h; | 81 pNew->h = h; |
| 82 pNew->dirfd = dirfd; |
| 69 pNew->zPath = zFilename; | 83 pNew->zPath = zFilename; |
| 70 - if( memcmp(pVfs->zName,"unix-excl",10)==0 ){ | 84 - if( memcmp(pVfs->zName,"unix-excl",10)==0 ){ |
| 71 + if( strcmp(pVfs->zName,"unix-excl")==0 ){ | 85 + if( strcmp(pVfs->zName,"unix-excl")==0 ){ |
| 72 pNew->ctrlFlags = UNIXFILE_EXCL; | 86 pNew->ctrlFlags = UNIXFILE_EXCL; |
| 73 }else{ | 87 }else{ |
| 74 pNew->ctrlFlags = 0; | 88 pNew->ctrlFlags = 0; |
| 75 diff --git src/vdbeapi.c src/vdbeapi.c | 89 diff --git a/third_party/sqlite/src/src/vdbeapi.c b/third_party/sqlite/src/src/v
dbeapi.c |
| 76 index 90baacc..80ceb9f 100644 | 90 index 90baacc..80ceb9f 100644 |
| 77 --- src/vdbeapi.c | 91 --- a/third_party/sqlite/src/src/vdbeapi.c |
| 78 +++ src/vdbeapi.c | 92 +++ b/third_party/sqlite/src/src/vdbeapi.c |
| 79 @@ -1222,7 +1222,7 @@ int sqlite3VdbeParameterIndex(Vdbe *p, const char *zName,
int nName){ | 93 @@ -1222,7 +1222,7 @@ int sqlite3VdbeParameterIndex(Vdbe *p, const char *zName,
int nName){ |
| 80 if( zName ){ | 94 if( zName ){ |
| 81 for(i=0; i<p->nVar; i++){ | 95 for(i=0; i<p->nVar; i++){ |
| 82 const char *z = p->azVar[i]; | 96 const char *z = p->azVar[i]; |
| 83 - if( z && memcmp(z,zName,nName)==0 && z[nName]==0 ){ | 97 - if( z && memcmp(z,zName,nName)==0 && z[nName]==0 ){ |
| 84 + if( z && strncmp(z,zName,nName)==0 && z[nName]==0 ){ | 98 + if( z && strncmp(z,zName,nName)==0 && z[nName]==0 ){ |
| 85 return i+1; | 99 return i+1; |
| 86 } | 100 } |
| 87 } | 101 } |
| 102 -- |
| 103 2.2.1 |
| 104 |
| OLD | NEW |