Blame SOURCES/sqlite-3.26.0-CVE-2019-19924.patch

4bd5ce
From 6b06304c2a46e17a6dc4402eadc75ccac24da893 Mon Sep 17 00:00:00 2001
4bd5ce
From: Ondrej Dubaj <odubaj@redhat.com>
4bd5ce
Date: Fri, 17 Jan 2020 13:03:54 +0100
4bd5ce
Subject: [PATCH] When an error occurs while rewriting the parser tree for
4bd5ce
 window functions in the sqlite3WindowRewrite() routine, make sure that
4bd5ce
 pParse->nErr is set, and make sure that this shuts down any subsequent code
4bd5ce
 generation that might depend on the transformations that were implemented. 
4bd5ce
 This fixes a problem discovered by the Yongheng and Rui fuzzer.
4bd5ce
4bd5ce
---
4bd5ce
 src/expr.c    | 1 +
4bd5ce
 src/vdbeaux.c | 3 ++-
4bd5ce
 src/window.c  | 5 +++++
4bd5ce
 3 files changed, 8 insertions(+), 1 deletion(-)
4bd5ce
4bd5ce
diff --git a/src/expr.c b/src/expr.c
4bd5ce
index d4eb9de..b081ca2 100644
4bd5ce
--- a/src/expr.c
4bd5ce
+++ b/src/expr.c
4bd5ce
@@ -344,6 +344,7 @@ static int codeCompare(
4bd5ce
   int addr;
4bd5ce
   CollSeq *p4;
4bd5ce
 
4bd5ce
+  if( pParse->nErr ) return 0;
4bd5ce
   p4 = sqlite3BinaryCompareCollSeq(pParse, pLeft, pRight);
4bd5ce
   p5 = binaryCompareP5(pLeft, pRight, jumpIfNull);
4bd5ce
   addr = sqlite3VdbeAddOp4(pParse->pVdbe, opcode, in2, dest, in1,
4bd5ce
diff --git a/src/vdbeaux.c b/src/vdbeaux.c
4bd5ce
index f1496a3..b74141b 100644
4bd5ce
--- a/src/vdbeaux.c
4bd5ce
+++ b/src/vdbeaux.c
4bd5ce
@@ -1160,7 +1160,8 @@ void sqlite3VdbeSetP4KeyInfo(Parse *pParse, Index *pIdx){
4bd5ce
 */
4bd5ce
 static void vdbeVComment(Vdbe *p, const char *zFormat, va_list ap){
4bd5ce
   assert( p->nOp>0 || p->aOp==0 );
4bd5ce
-  assert( p->aOp==0 || p->aOp[p->nOp-1].zComment==0 || p->db->mallocFailed );
4bd5ce
+  assert( p->aOp==0 || p->aOp[p->nOp-1].zComment==0 || p->db->mallocFailed
4bd5ce
+          || p->pParse->nErr>0 );
4bd5ce
   if( p->nOp ){
4bd5ce
     assert( p->aOp );
4bd5ce
     sqlite3DbFree(p->db, p->aOp[p->nOp-1].zComment);
4bd5ce
diff --git a/src/window.c b/src/window.c
4bd5ce
index f5deae9..56c0145 100644
4bd5ce
--- a/src/window.c
4bd5ce
+++ b/src/window.c
4bd5ce
@@ -843,6 +843,11 @@ int sqlite3WindowRewrite(Parse *pParse, Select *p){
4bd5ce
     if( db->mallocFailed ) rc = SQLITE_NOMEM;
4bd5ce
   }
4bd5ce
 
4bd5ce
+  if( rc && pParse->nErr==0 ){
4bd5ce
+    assert( pParse->db->mallocFailed );
4bd5ce
+    return SQLITE_NOMEM;
4bd5ce
+  }
4bd5ce
+
4bd5ce
   return rc;
4bd5ce
 }
4bd5ce
 
4bd5ce
-- 
4bd5ce
2.19.1
4bd5ce