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

ec7966
From 1986c6384122947b10804cbc5c4d7af85e097404 Mon Sep 17 00:00:00 2001
ec7966
From: Ondrej Dubaj <odubaj@redhat.com>
ec7966
Date: Mon, 20 Jan 2020 10:09:55 +0100
ec7966
Subject: [PATCH] Fix the zipfile extension so that INSERT works even if the
ec7966
 pathname of
ec7966
ec7966
the file being inserted is a NULL.  Bug discovered by the
ec7966
Yongheng and Rui fuzzer.
ec7966
---
ec7966
 ext/misc/zipfile.c |  1 +
ec7966
 test/zipfile.test  | 13 +++++++++++++
ec7966
 2 files changed, 14 insertions(+)
ec7966
ec7966
diff --git a/ext/misc/zipfile.c b/ext/misc/zipfile.c
ec7966
index e57dc38..6f48d0f 100644
ec7966
--- a/ext/misc/zipfile.c
ec7966
+++ b/ext/misc/zipfile.c
ec7966
@@ -1618,6 +1618,7 @@ static int zipfileUpdate(
ec7966
 
ec7966
     if( rc==SQLITE_OK ){
ec7966
       zPath = (const char*)sqlite3_value_text(apVal[2]);
ec7966
+      if( zPath==0 ) zPath = "";
ec7966
       nPath = (int)strlen(zPath);
ec7966
       mTime = zipfileGetTime(apVal[4]);
ec7966
     }
ec7966
diff --git a/test/zipfile.test b/test/zipfile.test
ec7966
index 2bab066..5bca10b 100644
ec7966
--- a/test/zipfile.test
ec7966
+++ b/test/zipfile.test
ec7966
@@ -795,4 +795,17 @@ if {$tcl_platform(platform)!="windows"} {
ec7966
   } {. ./x1.txt ./x2.txt}
ec7966
 }
ec7966
 
ec7966
+# 2019-12-18 Yongheng and Rui fuzzer
ec7966
+#
ec7966
+do_execsql_test 13.10 {
ec7966
+  DROP TABLE IF EXISTS t0;
ec7966
+  DROP TABLE IF EXISTS t1;
ec7966
+  CREATE TABLE t0(a,b,c,d,e,f,g);
ec7966
+  REPLACE INTO t0(c,b,f) VALUES(10,10,10);
ec7966
+  CREATE VIRTUAL TABLE t1 USING zipfile('h.zip');
ec7966
+  REPLACE INTO t1 SELECT * FROM t0;
ec7966
+  SELECT quote(name),quote(mode),quote(mtime),quote(sz),quote(rawdata),
ec7966
+         quote(data),quote(method) FROM t1;
ec7966
+} {'' 10 10 2 X'3130' X'3130' 0}
ec7966
+
ec7966
 finish_test
ec7966
-- 
ec7966
2.19.1
ec7966