From c0c66d213b4b6deb0a5e9a688810d2e9674d3ecf Mon Sep 17 00:00:00 2001 From: Shubham Agrawal Date: Tue, 1 Oct 2019 18:12:49 +0000 Subject: sqlite3: Security fix for CVE-2019-8457 Signed-off-by: Shubham Agrawal [Cleaned up patch] Signed-off-by: Armin Kuster --- .../sqlite/files/CVE-2019-8457.patch | 126 +++++++++++++++++++++ meta/recipes-support/sqlite/sqlite3_3.23.1.bb | 1 + 2 files changed, 127 insertions(+) create mode 100644 meta/recipes-support/sqlite/files/CVE-2019-8457.patch (limited to 'meta') diff --git a/meta/recipes-support/sqlite/files/CVE-2019-8457.patch b/meta/recipes-support/sqlite/files/CVE-2019-8457.patch new file mode 100644 index 0000000000..5883774e4a --- /dev/null +++ b/meta/recipes-support/sqlite/files/CVE-2019-8457.patch @@ -0,0 +1,126 @@ +From fbf2392644f0ae4282fa4583c9bb67260995d983 Mon Sep 17 00:00:00 2001 +From: Shubham Agrawal +Date: Mon, 23 Sep 2019 20:58:47 +0000 +Subject: [PATCH] sqlite: fix for CVE-2019-8457 + +Upstream-Status: Backport +CVE: CVE-2019-8457 +Signed-off-by: Shubham Agrawal +--- + sqlite3.c | 50 +++++++++++++++++++++++++++++++------------------- + 1 file changed, 31 insertions(+), 19 deletions(-) + +diff --git a/sqlite3.c b/sqlite3.c +index 00513d4..5c8c7f4 100644 +--- a/sqlite3.c ++++ b/sqlite3.c +@@ -172325,6 +172325,33 @@ + } + + ++/* Allocate and initialize a new dynamic string object */ ++StrAccum *sqlite3_str_new(sqlite3 *db){ ++ StrAccum *p = sqlite3DbMallocRaw(db, sizeof(*p)); ++ if( p ){ ++ sqlite3StrAccumInit(p, db, 0, 0, SQLITE_MAX_LENGTH); ++ } ++ return p; ++} ++ ++/* Finalize a string created using sqlite3_str_new(). ++*/ ++ ++char *sqlite3_str_finish(StrAccum *p){ ++ char *z; ++ if( p ){ ++ z = sqlite3StrAccumFinish(p); ++ sqlite3DbFree(p->db, p); ++ }else{ ++ z = 0; ++ } ++ return z; ++} ++/* Return any error code associated with p */ ++int sqlite3_str_errcode(StrAccum *p){ ++ return p ? p->accError : SQLITE_NOMEM; ++} ++ + /* + ** Implementation of a scalar function that decodes r-tree nodes to + ** human readable strings. This can be used for debugging and analysis. +@@ -172342,49 +172369,53 @@ + ** *2 coordinates. + */ + static void rtreenode(sqlite3_context *ctx, int nArg, sqlite3_value **apArg){ +- char *zText = 0; ++ + RtreeNode node; + Rtree tree; + int ii; ++ int nData; ++ int errCode; ++ StrAccum *pOut; + + UNUSED_PARAMETER(nArg); + memset(&node, 0, sizeof(RtreeNode)); + memset(&tree, 0, sizeof(Rtree)); + tree.nDim = (u8)sqlite3_value_int(apArg[0]); ++ if( tree.nDim<1 || tree.nDim>5 ) return; + tree.nDim2 = tree.nDim*2; + tree.nBytesPerCell = 8 + 8 * tree.nDim; + node.zData = (u8 *)sqlite3_value_blob(apArg[1]); ++ nData = sqlite3_value_bytes(apArg[1]); ++ if( nData<4 ) return; ++ if( nData0 ) sqlite3StrAccumAppend(pOut, " ", 1); ++ sqlite3XPrintf(pOut, "{%lld", cell.iRowid); ++ + for(jj=0; jj