Browse code

Upgrade sqlite to v3.32.1 & fix CVE-2020-15358.

Change-Id: I74b2338769c44164de6d6dbe7e0a686142d2c9d3
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/10018
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Tapas Kundu <tkundu@vmware.com>

Shreyas B authored on 2020/07/03 21:45:42
Showing 5 changed files
1 1
deleted file mode 100644
... ...
@@ -1,14 +0,0 @@
1
-diff -dupr a/sqlite3.c b/sqlite3.c
2
-+++ b/sqlite3.c	2017-07-14 14:11:49.114553056 -0700
3
-@@ -167480,6 +167480,10 @@ static int getNodeSize(
4
-     rc = getIntFromStmt(db, zSql, &pRtree->iNodeSize);
5
-     if( rc!=SQLITE_OK ){
6
-       *pzErr = sqlite3_mprintf("%s", sqlite3_errmsg(db));
7
-+    }else if( pRtree->iNodeSize<(512-64) ){
8
-+      rc = SQLITE_CORRUPT;
9
-+      *pzErr = sqlite3_mprintf("undersize RTree blobs in \"%q_node\"",
10
-+                               pRtree->zName);
11
-     }
12
-   }
13
- 
14 1
deleted file mode 100644
... ...
@@ -1,79 +0,0 @@
1
-From 4db7ab53f9c30e2e22731ace93ab6b18eef6c4ae Mon Sep 17 00:00:00 2001
2
-From: dan <dan@noemail.net>
3
-Date: Fri, 3 Apr 2020 11:52:59 +0000
4
-Subject: [PATCH] Do not suppress errors when resolving references in an ORDER
5
- BY clause belonging to a compound SELECT within a view or trigger within
6
- ALTER TABLE. Fix for ticket [a10a14e9b4ba2].
7
-
8
-FossilOrigin-Name: 684293882c302600e112cf52553c19d84fdb31663d96e5dd7f8ac17dda00a026
9
-
10
-From c415d91007e1680e4eb17def583b202c3c83c718 Mon Sep 17 00:00:00 2001
11
-From: drh <drh@noemail.net>
12
-Date: Fri, 3 Apr 2020 13:19:03 +0000
13
-Subject: [PATCH] In the event of a semantic error in an aggregate query,
14
- early-out the resetAccumulator() function to prevent problems due to
15
- incomplete or incorrect initialization of the AggInfo object. Fix for ticket
16
- [af4556bb5c285c08].
17
-
18
-From fb99e388ec7f30fe43e4878236e3695ff24ae58d Mon Sep 17 00:00:00 2001
19
-From: dan <dan@noemail.net>
20
-Date: Fri, 3 Apr 2020 11:20:40 +0000
21
-Subject: [PATCH] Fix a case when a pointer might be used after being freed in
22
- the ALTER TABLE code. Fix for [4722bdab08cb1].
23
-
24
-FossilOrigin-Name: d09f8c3621d5f7f8c6d99d7d82bcaa8421855b3f470bea2b26c858106382b906
25
-
26
-Upstream Patch Source: https://www3.sqlite.org/cgi/src/info/b64674919f673602
27
-Upstream Patch Source: https://www.sqlite.org/src/info/d09f8c3621d5f7f8
28
-
29
-diff --git a/sqlite3.c b/sqlite3.c
30
-index 55dc686..82eb682 100644
31
-+++ b/sqlite3.c
32
-@@ -97942,7 +97942,7 @@ static int resolveOrderByTermToExprList(
33
-   nc.nErr = 0;
34
-   db = pParse->db;
35
-   savedSuppErr = db->suppressErr;
36
--  db->suppressErr = 1;
37
-+  if( IN_RENAME_OBJECT==0 ) db->suppressErr = 1;
38
-   rc = sqlite3ResolveExprNames(&nc, pE);
39
-   db->suppressErr = savedSuppErr;
40
-   if( rc ) return 0;
41
-@@ -105374,6 +105374,21 @@ static void renameWalkWith(Walker *pWalker, Select *pSelect){
42
-   }
43
- }
44
- 
45
-+/*
46
-+** Unmap all tokens in the IdList object passed as the second argument.
47
-+*/
48
-+static void unmapColumnIdlistNames(
49
-+  Parse *pParse,
50
-+  IdList *pIdList
51
-+){
52
-+  if( pIdList ){
53
-+    int ii;
54
-+    for(ii=0; ii<pIdList->nId; ii++){
55
-+      sqlite3RenameTokenRemap(pParse, 0, (void*)pIdList->a[ii].zName);
56
-+    }
57
-+  }
58
-+}
59
-+
60
- /*
61
- ** Walker callback used by sqlite3RenameExprUnmap().
62
- */
63
-@@ -105395,6 +105410,7 @@ static int renameUnmapSelectCb(Walker *pWalker, Select *p){
64
-     for(i=0; i<pSrc->nSrc; i++){
65
-       sqlite3RenameTokenRemap(pParse, 0, (void*)pSrc->a[i].zName);
66
-       if( sqlite3WalkExpr(pWalker, pSrc->a[i].pOn) ) return WRC_Abort;
67
-+      unmapColumnIdlistNames(pParse, pSrc->a[i].pUsing);
68
-     }
69
-   }
70
- 
71
-@@ -133217,6 +133233,7 @@ static void resetAccumulator(Parse *pParse, AggInfo *pAggInfo){
72
-   struct AggInfo_func *pFunc;
73
-   int nReg = pAggInfo->nFunc + pAggInfo->nColumn;
74
-   if( nReg==0 ) return;
75
-+  if( pParse->nErr ) return;
76
- #ifdef SQLITE_DEBUG
77
-   /* Verify that all AggInfo registers are within the range specified by
78
-   ** AggInfo.mnReg..AggInfo.mxReg */
79 1
new file mode 100644
... ...
@@ -0,0 +1,46 @@
0
+From b7cbf5c1b2a9e099eec176e1ebeb659427a20626 Mon Sep 17 00:00:00 2001
1
+From: drh <drh@noemail.net>
2
+Date: Mon, 15 Jun 2020 13:51:34 +0000
3
+Subject: [PATCH] Fix a defect in the query-flattener optimization identified
4
+ by ticket [8f157e8010b22af0].
5
+
6
+FossilOrigin-Name: 10fa79d00f8091e5748c245f4cae5b5f499a5f8db20da741c130e05a21ede443
7
+---
8
+--- a/sqlite3.c	2020-07-03 17:19:04.330032521 +0530
9
+@@ -18462,6 +18462,7 @@ struct Select {
10
+ #define SF_WhereBegin    0x0080000 /* Really a WhereBegin() call.  Debug Only */
11
+ #define SF_WinRewrite    0x0100000 /* Window function rewrite accomplished */
12
+ #define SF_View          0x0200000 /* SELECT statement is a view */
13
++#define SF_NoopOrderBy   0x0400000 /* ORDER BY is ignored for this query */
14
+ 
15
+ /*
16
+ ** The results of a SELECT can be distributed in several ways, as defined
17
+@@ -131551,9 +131552,7 @@ static int multiSelect(
18
+                           selectOpName(p->op)));
19
+         rc = sqlite3Select(pParse, p, &uniondest);
20
+         testcase( rc!=SQLITE_OK );
21
+-        /* Query flattening in sqlite3Select() might refill p->pOrderBy.
22
+-        ** Be sure to delete p->pOrderBy, therefore, to avoid a memory leak. */
23
+-        sqlite3ExprListDelete(db, p->pOrderBy);
24
++        assert( p->pOrderBy==0 );
25
+         pDelete = p->pPrior;
26
+         p->pPrior = pPrior;
27
+         p->pOrderBy = 0;
28
+@@ -132939,7 +132938,7 @@ static int flattenSubquery(
29
+     ** We look at every expression in the outer query and every place we see
30
+     ** "a" we substitute "x*3" and every place we see "b" we substitute "y+10".
31
+     */
32
+-    if( pSub->pOrderBy ){
33
++    if( pSub->pOrderBy && (pParent->selFlags & SF_NoopOrderBy)==0 ){
34
+       /* At this point, any non-zero iOrderByCol values indicate that the
35
+       ** ORDER BY column expression is identical to the iOrderByCol'th
36
+       ** expression returned by SELECT statement pSub. Since these values
37
+@@ -134621,6 +134620,7 @@ SQLITE_PRIVATE int sqlite3Select(
38
+     sqlite3ExprListDelete(db, p->pOrderBy);
39
+     p->pOrderBy = 0;
40
+     p->selFlags &= ~SF_Distinct;
41
++    p->selFlags |= SF_NoopOrderBy;
42
+   }
43
+   sqlite3SelectPrep(pParse, p, 0);
44
+   if( pParse->nErr || db->mallocFailed ){
0 45
deleted file mode 100644
... ...
@@ -1,81 +0,0 @@
1
-diff -ru a/sqlite3.c b/sqlite3.c
2
-+++ b/sqlite3.c	2020-04-15 20:18:27.531621936 +0000
3
-@@ -17428,8 +17428,11 @@
4
- */
5
- #ifndef SQLITE_OMIT_VIRTUALTABLE
6
- #  define IsVirtual(X)      ((X)->nModuleArg)
7
-+#  define ExprIsVtab(X)  \
8
-+              ((X)->op==TK_COLUMN && (X)->y.pTab!=0 && (X)->y.pTab->nModuleArg)
9
- #else
10
- #  define IsVirtual(X)      0
11
-+#  define ExprIsVtab(X)     0
12
- #endif
13
- 
14
- /*
15
-@@ -104133,19 +104136,25 @@
16
-     case TK_LT:
17
-     case TK_LE:
18
-     case TK_GT:
19
--    case TK_GE:
20
-+    case TK_GE: {
21
-+      Expr *pLeft = pExpr->pLeft;
22
-+      Expr *pRight = pExpr->pRight;      
23
-       testcase( pExpr->op==TK_EQ );
24
-       testcase( pExpr->op==TK_NE );
25
-       testcase( pExpr->op==TK_LT );
26
-       testcase( pExpr->op==TK_LE );
27
-       testcase( pExpr->op==TK_GT );
28
-       testcase( pExpr->op==TK_GE );
29
--      if( (pExpr->pLeft->op==TK_COLUMN && IsVirtual(pExpr->pLeft->y.pTab))
30
--       || (pExpr->pRight->op==TK_COLUMN && IsVirtual(pExpr->pRight->y.pTab))
31
-+      /* The y.pTab=0 assignment in wherecode.c always happens after the
32
-+      ** impliesNotNullRow() test */
33
-+      if( (pLeft->op==TK_COLUMN && ALWAYS(pLeft->y.pTab!=0)
34
-+                               && IsVirtual(pLeft->y.pTab))
35
-+       || (pRight->op==TK_COLUMN && ALWAYS(pRight->y.pTab!=0)
36
-+                               && IsVirtual(pRight->y.pTab))
37
-       ){
38
--       return WRC_Prune;
39
-+        return WRC_Prune;
40
-       }
41
--
42
-+    }
43
-     default:
44
-       return WRC_Continue;
45
-   }
46
-@@ -142591,7 +142600,8 @@
47
-     **       MATCH(expression,vtab_column)
48
-     */
49
-     pCol = pList->a[1].pExpr;
50
--    if( pCol->op==TK_COLUMN && IsVirtual(pCol->y.pTab) ){
51
-+    testcase( pCol->op==TK_COLUMN && pCol->y.pTab==0 );
52
-+    if( ExprIsVtab(pCol) ){
53
-       for(i=0; i<ArraySize(aOp); i++){
54
-         if( sqlite3StrICmp(pExpr->u.zToken, aOp[i].zOp)==0 ){
55
-           *peOp2 = aOp[i].eOp2;
56
-@@ -142613,7 +142623,8 @@
57
-     ** with function names in an arbitrary case.
58
-     */
59
-     pCol = pList->a[0].pExpr;
60
--    if( pCol->op==TK_COLUMN && IsVirtual(pCol->y.pTab) ){
61
-+    testcase( pCol->op==TK_COLUMN && pCol->y.pTab==0 );
62
-+    if( ExprIsVtab(pCol) ){    
63
-       sqlite3_vtab *pVtab;
64
-       sqlite3_module *pMod;
65
-       void (*xNotUsed)(sqlite3_context*,int,sqlite3_value**);
66
-@@ -142636,10 +142647,12 @@
67
-     int res = 0;
68
-     Expr *pLeft = pExpr->pLeft;
69
-     Expr *pRight = pExpr->pRight;
70
--    if( pLeft->op==TK_COLUMN && IsVirtual(pLeft->y.pTab) ){
71
-+    testcase( pLeft->op==TK_COLUMN && pLeft->y.pTab==0 );
72
-+    if( ExprIsVtab(pLeft) ){    
73
-       res++;
74
-     }
75
--    if( pRight && pRight->op==TK_COLUMN && IsVirtual(pRight->y.pTab) ){
76
-+    testcase( pRight && pRight->op==TK_COLUMN && pRight->y.pTab==0 );
77
-+    if( pRight && ExprIsVtab(pRight) ){
78
-       res++;
79
-       SWAP(Expr*, pLeft, pRight);
80
-     }
... ...
@@ -1,7 +1,7 @@
1
-%define sourcever 3310100
1
+%define sourcever 3320100
2 2
 Summary:    A portable, high level programming interface to various calling conventions
3 3
 Name:           sqlite
4
-Version:        3.31.1
4
+Version:        3.32.1
5 5
 Release:        1%{?dist}
6 6
 License:        Public Domain
7 7
 URL:            http://www.sqlite.org
... ...
@@ -9,9 +9,8 @@ Group:          System Environment/GeneralLibraries
9 9
 Vendor:         VMware, Inc.
10 10
 Distribution:   Photon
11 11
 Source0:        http://sqlite.org/2020/%{name}-autoconf-%{sourcever}.tar.gz
12
-%define sha1    sqlite=0c30f5b22152a8166aa3bebb0f4bc1f3e9cc508b
13
-Patch0:         sqlite-CVE-2020-11656.patch
14
-Patch1:         sqlite-CVE-2020-9327.patch
12
+%define sha1    sqlite=3d34d86ef726b66edeb0b93b2a4c0d036ea8dcf3
13
+Patch0:         sqlite-CVE-2020-15358.patch
15 14
 Obsoletes:      sqlite-autoconf
16 15
 Obsoletes:      sqlite-devel <= 3.27.2-5
17 16
 Requires:       sqlite-libs = %{version}-%{release}
... ...
@@ -41,7 +40,6 @@ The sqlite3 library.
41 41
 %prep
42 42
 %setup -q -n %{name}-autoconf-%{sourcever}
43 43
 %patch0 -p1
44
-%patch1 -p1
45 44
 
46 45
 %build
47 46
 %configure \
... ...
@@ -91,9 +89,12 @@ rm -rf %{buildroot}/*
91 91
 %{_libdir}/libsqlite3.so.0
92 92
 
93 93
 %changelog
94
+*   Fri Jul 03 2020 Shreyas B <shreyasb@vmware.com> 3.32.1-1
95
+-   Upgrade to 3.32.1 & fix CVE-2020-15358
96
+-   CVE-2020-13630 CVE-2020-13434 CVE-2020-13435 CVE-2020-13631 CVE-2020-13632
94 97
 *   Thu May 14 2020 Ankit Jain <ankitja@vmware.com> 3.31.1-1
95 98
 -   Updated to 3.31.1
96
-*   Wed Feb 3 2019 Michelle Wang <michellew@vmware.com> 3.26.0-1
99
+*   Sun Feb 3 2019 Michelle Wang <michellew@vmware.com> 3.26.0-1
97 100
 -   Upgrade to 3.26.0 for a critical Vulnerability named 'Magallan'.
98 101
 *   Fri Sep 21 2018 Srinidhi Rao <srinidhir@vmware.com> 3.25.1-1
99 102
 -   Upgrade to version 3.25.1