|
Line 0
Link Here
|
|
|
1 |
# Fix for CVE-2018-8740: https://nvd.nist.gov/vuln/detail/CVE-2018-8740 |
| 2 |
# Detect databases whose schema is corrupted using a CREATE TABLE AS statement and issue an appropriate error message. |
| 3 |
# Commit [d75e6765]: https://www.sqlite.org/src/info/d75e67654aa9620b |
| 4 |
# Description: https://bugs.launchpad.net/ubuntu/+source/sqlite3/+bug/1756349 |
| 5 |
|
| 6 |
--- uppsrc/plugin/sqlite3/lib/sqlite3.c.orig 2018-03-31 06:10:16 UTC |
| 7 |
+++ uppsrc/plugin/sqlite3/lib/sqlite3.c |
| 8 |
@@ -103474,8 +103474,6 @@ SQLITE_PRIVATE void sqlite3EndTable( |
| 9 |
p = pParse->pNewTable; |
| 10 |
if( p==0 ) return; |
| 11 |
|
| 12 |
- assert( !db->init.busy || !pSelect ); |
| 13 |
- |
| 14 |
/* If the db->init.busy is 1 it means we are reading the SQL off the |
| 15 |
** "sqlite_master" or "sqlite_temp_master" table on the disk. |
| 16 |
** So do not write to the disk again. Extract the root page number |
| 17 |
@@ -103486,6 +103484,10 @@ SQLITE_PRIVATE void sqlite3EndTable( |
| 18 |
** table itself. So mark it read-only. |
| 19 |
*/ |
| 20 |
if( db->init.busy ){ |
| 21 |
+ if( pSelect ){ |
| 22 |
+ sqlite3ErrorMsg(pParse, ""); |
| 23 |
+ return; |
| 24 |
+ } |
| 25 |
p->tnum = db->init.newTnum; |
| 26 |
if( p->tnum==1 ) p->tabFlags |= TF_Readonly; |
| 27 |
} |
| 28 |
@@ -117813,7 +117815,7 @@ static void corruptSchema( |
| 29 |
char *z; |
| 30 |
if( zObj==0 ) zObj = "?"; |
| 31 |
z = sqlite3MPrintf(db, "malformed database schema (%s)", zObj); |
| 32 |
- if( zExtra ) z = sqlite3MPrintf(db, "%z - %s", z, zExtra); |
| 33 |
+ if( zExtra && zExtra[0] ) z = sqlite3MPrintf(db, "%z - %s", z, zExtra); |
| 34 |
sqlite3DbFree(db, *pData->pzErrMsg); |
| 35 |
*pData->pzErrMsg = z; |
| 36 |
} |