summaryrefslogtreecommitdiffstats
path: root/poky/meta/recipes-support/sqlite/files/CVE-2018-8740.patch
blob: 5d95e37afe553a2783904b2ab3a5ca46d45cda40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
From 19aed4d2be46c4516caf2bee31f79044bbd1d57d Mon Sep 17 00:00:00 2001
From: Sinan Kaya <okaya@kernel.org>
Date: Fri, 21 Sep 2018 16:22:01 +0000
Subject: [PATCH] Detect databases whose schema is corrupted using a CREATE TABLE AS statement and issue an appropriate error message

Upstream-Status: Backport [ https://www.sqlite.org/cgi/src/vdiff?from=1774f1c3baf0bc3d&to=d75e67654aa9620b&diff=1&w]
Signed-off-by: Sinan Kaya <okaya@kernel.org>
---
 sqlite3.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/sqlite3.c b/sqlite3.c
index 73c69ef..6863bc6 100644
--- a/sqlite3.c
+++ b/sqlite3.c
@@ -103474,8 +103474,6 @@ SQLITE_PRIVATE void sqlite3EndTable(
   p = pParse->pNewTable;
   if( p==0 ) return;
 
-  assert( !db->init.busy || !pSelect );
-
   /* If the db->init.busy is 1 it means we are reading the SQL off the
   ** "sqlite_master" or "sqlite_temp_master" table on the disk.
   ** So do not write to the disk again.  Extract the root page number
@@ -103486,6 +103484,10 @@ SQLITE_PRIVATE void sqlite3EndTable(
   ** table itself.  So mark it read-only.
   */
   if( db->init.busy ){
+    if( pSelect ){
+     sqlite3ErrorMsg(pParse, "");
+     return;
+    }
     p->tnum = db->init.newTnum;
     if( p->tnum==1 ) p->tabFlags |= TF_Readonly;
   }
@@ -117813,7 +117815,7 @@ static void corruptSchema(
     char *z;
     if( zObj==0 ) zObj = "?";
     z = sqlite3MPrintf(db, "malformed database schema (%s)", zObj);
-    if( zExtra ) z = sqlite3MPrintf(db, "%z - %s", z, zExtra);
+    if( zExtra && zExtra[0] ) z = sqlite3MPrintf(db, "%z - %s", z, zExtra);
     sqlite3DbFree(db, *pData->pzErrMsg);
     *pData->pzErrMsg = z;
   }
-- 
2.19.0

OpenPOWER on IntegriCloud