Skip to content
This repository was archived by the owner on Dec 21, 2024. It is now read-only.

Commit 9c46de6

Browse files
zezeozueBryan Ferris
authored andcommitted
[RESTRICT AUTOMERGE] Apply security patch to sqlite 3.18
This patch fixes CVE-2019-9936CVE-2019-5018CVE-2019-8457 in b/140181188 b/140180629 and b/140182003 respectively Download from https://www.sqlite.org/src/info/b54aa18b0fe4d683 Get the Tarball or ZIP Archive, unzip it on linux machine then run: mkdir bld; cd bld; ../configure; make sqlite3.c Copy sqlite3.c, sqlite3.h, sqlite3ext.h, shell.c from bld directory to dist/orig. dist contains a copy of dist/orig, but with the Android.patch file applied. Test: select sqlite_version() - returns 3.18.2 Test: atest cts/SQLiteDatabaseTest all passed. Bug: 140181188 Bug: 140180629 Bug: 140182003 Merged-In: Iad8c3d1d74d8591a75a4c033c8bf9d3956d2fe4f Change-Id: Idab253d25374ef6c60e753086d9d8ba12f365697
1 parent 28c3d3b commit 9c46de6

File tree

5 files changed

+25
-13
lines changed

5 files changed

+25
-13
lines changed

README.version

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
URL: https://www.sqlite.org/src/info/4bb21d8205b3c72b
2-
Version: 3.18.2 4bb21d8205b3c72b94442018a0544ecc55e3320ef2593f0e3350142b7f2a7663
3-
This patch fixes Magellan SQLite Security Vulnerability as in b/121156452
1+
URL: https://www.sqlite.org/src/info/b54aa18b0fe4d683
2+
Version: 3.18.2 b54aa18b0fe4d683c602ed2ba59ded6c33168982d14ea14a12b4e00cde8bf973
3+
This patch fixes CVE-2019-9936,CVE-2019-5018,CVE-2019-8457 in b/140181188 b/140180629 and b/140182003 respectively
44
BugComponent: 24950

dist/orig/sqlite3.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ extern "C" {
400400
*/
401401
#define SQLITE_VERSION "3.18.2"
402402
#define SQLITE_VERSION_NUMBER 3018002
403-
#define SQLITE_SOURCE_ID "2018-12-19 01:38:18 4bb21d8205b3c72b94442018a0544ecc55e3320ef2593f0e3350142b7f2a7663"
403+
#define SQLITE_SOURCE_ID "2019-09-03 19:40:52 b54aa18b0fe4d683c602ed2ba59ded6c33168982d14ea14a12b4e00cde8bf973"
404404

405405
/*
406406
** CAPI3REF: Run-Time Library Version Numbers
@@ -167025,6 +167025,7 @@ static int rtreeInit(
167025167025
}
167026167026

167027167027

167028+
#if defined(SQLITE_TEST)
167028167029
/*
167029167030
** Implementation of a scalar function that decodes r-tree nodes to
167030167031
** human readable strings. This can be used for debugging and analysis.
@@ -167086,6 +167087,7 @@ static void rtreenode(sqlite3_context *ctx, int nArg, sqlite3_value **apArg){
167086167087

167087167088
sqlite3_result_text(ctx, zText, -1, sqlite3_free);
167088167089
}
167090+
#endif
167089167091

167090167092
/* This routine implements an SQL function that returns the "depth" parameter
167091167093
** from the front of a blob that is an r-tree node. For example:
@@ -167115,9 +167117,11 @@ static void rtreedepth(sqlite3_context *ctx, int nArg, sqlite3_value **apArg){
167115167117
*/
167116167118
SQLITE_PRIVATE int sqlite3RtreeInit(sqlite3 *db){
167117167119
const int utf8 = SQLITE_UTF8;
167118-
int rc;
167120+
int rc = SQLITE_OK;
167119167121

167122+
#if defined(SQLITE_TEST)
167120167123
rc = sqlite3_create_function(db, "rtreenode", 2, utf8, 0, rtreenode, 0, 0);
167124+
#endif
167121167125
if( rc==SQLITE_OK ){
167122167126
rc = sqlite3_create_function(db, "rtreedepth", 1, utf8, 0,rtreedepth, 0, 0);
167123167127
}
@@ -189086,7 +189090,9 @@ static int fts5HashEntrySort(
189086189090
for(iSlot=0; iSlot<pHash->nSlot; iSlot++){
189087189091
Fts5HashEntry *pIter;
189088189092
for(pIter=pHash->aSlot[iSlot]; pIter; pIter=pIter->pHashNext){
189089-
if( pTerm==0 || 0==memcmp(pIter->zKey, pTerm, nTerm) ){
189093+
if( pTerm==0
189094+
|| (strlen(pIter->zKey)>=nTerm && 0==memcmp(pIter->zKey, pTerm, nTerm))
189095+
){
189090189096
Fts5HashEntry *pEntry = pIter;
189091189097
pEntry->pScanNext = 0;
189092189098
for(i=0; ap[i]; i++){
@@ -198282,7 +198288,7 @@ static void fts5SourceIdFunc(
198282198288
){
198283198289
assert( nArg==0 );
198284198290
UNUSED_PARAM2(nArg, apUnused);
198285-
sqlite3_result_text(pCtx, "fts5: 2018-12-19 01:38:18 4bb21d8205b3c72b94442018a0544ecc55e3320ef2593f0e3350142b7f2a7663", -1, SQLITE_TRANSIENT);
198291+
sqlite3_result_text(pCtx, "fts5: 2019-09-03 19:40:52 b54aa18b0fe4d683c602ed2ba59ded6c33168982d14ea14a12b4e00cde8bf973", -1, SQLITE_TRANSIENT);
198286198292
}
198287198293

198288198294
static int fts5Init(sqlite3 *db){

dist/orig/sqlite3.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ extern "C" {
123123
*/
124124
#define SQLITE_VERSION "3.18.2"
125125
#define SQLITE_VERSION_NUMBER 3018002
126-
#define SQLITE_SOURCE_ID "2018-12-19 01:38:18 4bb21d8205b3c72b94442018a0544ecc55e3320ef2593f0e3350142b7f2a7663"
126+
#define SQLITE_SOURCE_ID "2019-09-03 19:40:52 b54aa18b0fe4d683c602ed2ba59ded6c33168982d14ea14a12b4e00cde8bf973"
127127

128128
/*
129129
** CAPI3REF: Run-Time Library Version Numbers

dist/sqlite3.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ extern "C" {
400400
*/
401401
#define SQLITE_VERSION "3.18.2"
402402
#define SQLITE_VERSION_NUMBER 3018002
403-
#define SQLITE_SOURCE_ID "2018-12-19 01:38:18 4bb21d8205b3c72b94442018a0544ecc55e3320ef2593f0e3350142b7f2a7663"
403+
#define SQLITE_SOURCE_ID "2019-09-03 19:40:52 b54aa18b0fe4d683c602ed2ba59ded6c33168982d14ea14a12b4e00cde8bf973"
404404

405405
/*
406406
** CAPI3REF: Run-Time Library Version Numbers
@@ -167038,6 +167038,7 @@ static int rtreeInit(
167038167038
}
167039167039

167040167040

167041+
#if defined(SQLITE_TEST)
167041167042
/*
167042167043
** Implementation of a scalar function that decodes r-tree nodes to
167043167044
** human readable strings. This can be used for debugging and analysis.
@@ -167099,6 +167100,7 @@ static void rtreenode(sqlite3_context *ctx, int nArg, sqlite3_value **apArg){
167099167100

167100167101
sqlite3_result_text(ctx, zText, -1, sqlite3_free);
167101167102
}
167103+
#endif
167102167104

167103167105
/* This routine implements an SQL function that returns the "depth" parameter
167104167106
** from the front of a blob that is an r-tree node. For example:
@@ -167128,9 +167130,11 @@ static void rtreedepth(sqlite3_context *ctx, int nArg, sqlite3_value **apArg){
167128167130
*/
167129167131
SQLITE_PRIVATE int sqlite3RtreeInit(sqlite3 *db){
167130167132
const int utf8 = SQLITE_UTF8;
167131-
int rc;
167133+
int rc = SQLITE_OK;
167132167134

167135+
#if defined(SQLITE_TEST)
167133167136
rc = sqlite3_create_function(db, "rtreenode", 2, utf8, 0, rtreenode, 0, 0);
167137+
#endif
167134167138
if( rc==SQLITE_OK ){
167135167139
rc = sqlite3_create_function(db, "rtreedepth", 1, utf8, 0,rtreedepth, 0, 0);
167136167140
}
@@ -189099,7 +189103,9 @@ static int fts5HashEntrySort(
189099189103
for(iSlot=0; iSlot<pHash->nSlot; iSlot++){
189100189104
Fts5HashEntry *pIter;
189101189105
for(pIter=pHash->aSlot[iSlot]; pIter; pIter=pIter->pHashNext){
189102-
if( pTerm==0 || 0==memcmp(pIter->zKey, pTerm, nTerm) ){
189106+
if( pTerm==0
189107+
|| (strlen(pIter->zKey)>=nTerm && 0==memcmp(pIter->zKey, pTerm, nTerm))
189108+
){
189103189109
Fts5HashEntry *pEntry = pIter;
189104189110
pEntry->pScanNext = 0;
189105189111
for(i=0; ap[i]; i++){
@@ -198295,7 +198301,7 @@ static void fts5SourceIdFunc(
198295198301
){
198296198302
assert( nArg==0 );
198297198303
UNUSED_PARAM2(nArg, apUnused);
198298-
sqlite3_result_text(pCtx, "fts5: 2018-12-19 01:38:18 4bb21d8205b3c72b94442018a0544ecc55e3320ef2593f0e3350142b7f2a7663", -1, SQLITE_TRANSIENT);
198304+
sqlite3_result_text(pCtx, "fts5: 2019-09-03 19:40:52 b54aa18b0fe4d683c602ed2ba59ded6c33168982d14ea14a12b4e00cde8bf973", -1, SQLITE_TRANSIENT);
198299198305
}
198300198306

198301198307
static int fts5Init(sqlite3 *db){

dist/sqlite3.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ extern "C" {
123123
*/
124124
#define SQLITE_VERSION "3.18.2"
125125
#define SQLITE_VERSION_NUMBER 3018002
126-
#define SQLITE_SOURCE_ID "2018-12-19 01:38:18 4bb21d8205b3c72b94442018a0544ecc55e3320ef2593f0e3350142b7f2a7663"
126+
#define SQLITE_SOURCE_ID "2019-09-03 19:40:52 b54aa18b0fe4d683c602ed2ba59ded6c33168982d14ea14a12b4e00cde8bf973"
127127

128128
/*
129129
** CAPI3REF: Run-Time Library Version Numbers

0 commit comments

Comments
 (0)