From 84c547cf6e2e136e206e6a0bd477230fd5ade134 Mon Sep 17 00:00:00 2001
From: Michael Kuhn <suraia@ikkoku.de>
Date: Thu, 20 Dec 2018 00:07:03 +0100
Subject: [PATCH] sqlite: add 3.26.0 (#10138)

---
 .../repos/builtin/packages/sqlite/package.py  | 33 ++-----------
 .../sqlite/remove_overflow_builtins.patch     | 48 -------------------
 .../builtin/packages/sqlite/sqlite_b0.patch   | 13 -----
 3 files changed, 4 insertions(+), 90 deletions(-)
 delete mode 100644 var/spack/repos/builtin/packages/sqlite/remove_overflow_builtins.patch
 delete mode 100644 var/spack/repos/builtin/packages/sqlite/sqlite_b0.patch

diff --git a/var/spack/repos/builtin/packages/sqlite/package.py b/var/spack/repos/builtin/packages/sqlite/package.py
index 175cfbb400..0df9d2816b 100644
--- a/var/spack/repos/builtin/packages/sqlite/package.py
+++ b/var/spack/repos/builtin/packages/sqlite/package.py
@@ -14,38 +14,13 @@ class Sqlite(AutotoolsPackage):
     """
     homepage = "https://www.sqlite.org"
 
-    version('3.25.3', '00ebf97be13928941940cc71de3d67e9f852698233cd98ce2d178fd08092f3dd',
-            url='https://www.sqlite.org/2018/sqlite-autoconf-3250300.tar.gz')
-    version('3.23.1', '0edbfd75ececb95e8e6448d6ff33df82774c9646',
-            url='https://www.sqlite.org/2018/sqlite-autoconf-3230100.tar.gz')
-    version('3.22.0', '2fb24ec12001926d5209d2da90d252b9825366ac',
-            url='https://www.sqlite.org/2018/sqlite-autoconf-3220000.tar.gz')
-    version('3.21.0', '7913de4c3126ba3c24689cb7a199ea31',
-            url='https://www.sqlite.org/2017/sqlite-autoconf-3210000.tar.gz')
-    version('3.20.0', 'e262a28b73cc330e7e83520c8ce14e4d',
-            url='https://www.sqlite.org/2017/sqlite-autoconf-3200000.tar.gz')
-    version('3.18.0', 'a6687a8ae1f66abc8df739aeadecfd0c',
-            url='https://www.sqlite.org/2017/sqlite-autoconf-3180000.tar.gz')
-    version('3.8.10.2', 'a18bfc015cd49a1e7a961b7b77bc3b37',
-            url='https://www.sqlite.org/2015/sqlite-autoconf-3081002.tar.gz')
-    version('3.8.5', '0544ef6d7afd8ca797935ccc2685a9ed',
-            url='https://www.sqlite.org/2014/sqlite-autoconf-3080500.tar.gz')
+    version('3.26.0', '9af2df1a6da5db6e2ecf3f463625f16740e036e9',
+            url='https://sqlite.org/2018/sqlite-autoconf-3260000.tar.gz')
+    # All versions prior to 3.26.0 are vulnerable to Magellan, see
+    # https://blade.tencent.com/magellan/index_en.html
 
     depends_on('readline')
 
-    # On some platforms (e.g., PPC) the include chain includes termios.h which
-    # defines a macro B0. Sqlite has a shell.c source file that declares a
-    # variable named B0 and will fail to compile when the macro is found. The
-    # following patch undefines the macro in shell.c
-    patch('sqlite_b0.patch', when='@3.18.0:3.21.0')
-
-    # Starting version 3.17.0, SQLite uses compiler built-ins
-    # __builtin_sub_overflow(), __builtin_add_overflow(), and
-    # __builtin_mul_overflow(), which are not supported by Intel compiler.
-    # Starting version 3.21.0 SQLite doesn't use the built-ins if Intel
-    # compiler is used.
-    patch('remove_overflow_builtins.patch', when='@3.17.0:3.20%intel')
-
     variant('functions', default=False,
             description='Provide mathematical and string extension functions '
                         'for SQL queries using the loadable extensions '
diff --git a/var/spack/repos/builtin/packages/sqlite/remove_overflow_builtins.patch b/var/spack/repos/builtin/packages/sqlite/remove_overflow_builtins.patch
deleted file mode 100644
index a0a5d2e3da..0000000000
--- a/var/spack/repos/builtin/packages/sqlite/remove_overflow_builtins.patch
+++ /dev/null
@@ -1,48 +0,0 @@
-diff --git a/sqlite3.c b/sqlite3.c
-index 4ec1271..8615169 100644
---- a/sqlite3.c
-+++ b/sqlite3.c
-@@ -29466,9 +29466,6 @@ SQLITE_PRIVATE int sqlite3SafetyCheckSickOrOk(sqlite3 *db){
- ** overflow, leave *pA unchanged and return 1.
- */
- SQLITE_PRIVATE int sqlite3AddInt64(i64 *pA, i64 iB){
--#if GCC_VERSION>=5004000
--  return __builtin_add_overflow(*pA, iB, pA);
--#else
-   i64 iA = *pA;
-   testcase( iA==0 ); testcase( iA==1 );
-   testcase( iB==-1 ); testcase( iB==0 );
-@@ -29483,12 +29480,8 @@ SQLITE_PRIVATE int sqlite3AddInt64(i64 *pA, i64 iB){
-   }
-   *pA += iB;
-   return 0; 
--#endif
- }
- SQLITE_PRIVATE int sqlite3SubInt64(i64 *pA, i64 iB){
--#if GCC_VERSION>=5004000
--  return __builtin_sub_overflow(*pA, iB, pA);
--#else
-   testcase( iB==SMALLEST_INT64+1 );
-   if( iB==SMALLEST_INT64 ){
-     testcase( (*pA)==(-1) ); testcase( (*pA)==0 );
-@@ -29498,12 +29491,8 @@ SQLITE_PRIVATE int sqlite3SubInt64(i64 *pA, i64 iB){
-   }else{
-     return sqlite3AddInt64(pA, -iB);
-   }
--#endif
- }
- SQLITE_PRIVATE int sqlite3MulInt64(i64 *pA, i64 iB){
--#if GCC_VERSION>=5004000
--  return __builtin_mul_overflow(*pA, iB, pA);
--#else
-   i64 iA = *pA;
-   if( iB>0 ){
-     if( iA>LARGEST_INT64/iB ) return 1;
-@@ -29519,7 +29508,6 @@ SQLITE_PRIVATE int sqlite3MulInt64(i64 *pA, i64 iB){
-   }
-   *pA = iA*iB;
-   return 0;
--#endif
- }
- 
- /*
diff --git a/var/spack/repos/builtin/packages/sqlite/sqlite_b0.patch b/var/spack/repos/builtin/packages/sqlite/sqlite_b0.patch
deleted file mode 100644
index 0be1bb95c1..0000000000
--- a/var/spack/repos/builtin/packages/sqlite/sqlite_b0.patch
+++ /dev/null
@@ -1,13 +0,0 @@
---- a/shell.c	2017-05-03 10:49:13.266276246 -0700
-+++ b/shell.c	2017-05-03 10:51:34.868963321 -0700
-@@ -198,6 +198,10 @@
- #define getrusage(A,B) memset(B,0,sizeof(*B))
- #endif
- 
-+#ifdef B0
-+#undef B0
-+#endif
-+
- /* Saved resource information for the beginning of an operation */
- static struct rusage sBegin;  /* CPU time at start */
- static sqlite3_int64 iBegin;  /* Wall-clock time at start */
-- 
GitLab