|
|
032533 |
From 16c5290d72cb8059e9dfe545613183b850fc44e4 Mon Sep 17 00:00:00 2001
|
|
|
032533 |
From: Ondrej Dubaj <odubaj@redhat.com>
|
|
|
032533 |
Date: Mon, 20 Jan 2020 10:26:35 +0100
|
|
|
032533 |
Subject: [PATCH] Fix the zipfile() function in the zipfile extension so that
|
|
|
032533 |
it is able to
|
|
|
032533 |
|
|
|
032533 |
deal with goofy filenames that contain embedded zeros.
|
|
|
032533 |
---
|
|
|
032533 |
ext/misc/zipfile.c | 4 ++--
|
|
|
032533 |
test/zipfile.test | 13 +++++++++++++
|
|
|
032533 |
2 files changed, 15 insertions(+), 2 deletions(-)
|
|
|
032533 |
|
|
|
032533 |
diff --git a/ext/misc/zipfile.c b/ext/misc/zipfile.c
|
|
|
032533 |
index 6f48d0f..e6141ef 100644
|
|
|
032533 |
--- a/ext/misc/zipfile.c
|
|
|
032533 |
+++ b/ext/misc/zipfile.c
|
|
|
032533 |
@@ -1632,7 +1632,7 @@ static int zipfileUpdate(
|
|
|
032533 |
zFree = sqlite3_mprintf("%s/", zPath);
|
|
|
032533 |
if( zFree==0 ){ rc = SQLITE_NOMEM; }
|
|
|
032533 |
zPath = (const char*)zFree;
|
|
|
032533 |
- nPath++;
|
|
|
032533 |
+ nPath = (int)strlen(zPath);
|
|
|
032533 |
}
|
|
|
032533 |
}
|
|
|
032533 |
|
|
|
032533 |
@@ -2033,11 +2033,11 @@ void zipfileStep(sqlite3_context *pCtx, int nVal, sqlite3_value **apVal){
|
|
|
032533 |
}else{
|
|
|
032533 |
if( zName[nName-1]!='/' ){
|
|
|
032533 |
zName = zFree = sqlite3_mprintf("%s/", zName);
|
|
|
032533 |
- nName++;
|
|
|
032533 |
if( zName==0 ){
|
|
|
032533 |
rc = SQLITE_NOMEM;
|
|
|
032533 |
goto zipfile_step_out;
|
|
|
032533 |
}
|
|
|
032533 |
+ nName = (int)strlen(zName);
|
|
|
032533 |
}else{
|
|
|
032533 |
while( nName>1 && zName[nName-2]=='/' ) nName--;
|
|
|
032533 |
}
|
|
|
032533 |
diff --git a/test/zipfile.test b/test/zipfile.test
|
|
|
032533 |
index 5bca10b..e4b8088 100644
|
|
|
032533 |
--- a/test/zipfile.test
|
|
|
032533 |
+++ b/test/zipfile.test
|
|
|
032533 |
@@ -808,4 +808,17 @@ do_execsql_test 13.10 {
|
|
|
032533 |
quote(data),quote(method) FROM t1;
|
|
|
032533 |
} {'' 10 10 2 X'3130' X'3130' 0}
|
|
|
032533 |
|
|
|
032533 |
+# 2019-12-23 Yongheng and Rui fuzzer
|
|
|
032533 |
+# Run using valgrind to see the problem.
|
|
|
032533 |
+#
|
|
|
032533 |
+do_execsql_test 14.10 {
|
|
|
032533 |
+ DROP TABLE t1;
|
|
|
032533 |
+ CREATE TABLE t1(x char);
|
|
|
032533 |
+ INSERT INTO t1(x) VALUES('1');
|
|
|
032533 |
+ INSERT INTO t1(x) SELECT zipfile(x, 'xyz') FROM t1;
|
|
|
032533 |
+ INSERT INTO t1(x) SELECT zipfile(x, 'uvw') FROM t1;
|
|
|
032533 |
+ SELECT count(*) FROM t1;
|
|
|
032533 |
+ PRAGMA integrity_check;
|
|
|
032533 |
+} {3 ok}
|
|
|
032533 |
+
|
|
|
032533 |
finish_test
|
|
|
032533 |
--
|
|
|
032533 |
2.19.1
|
|
|
032533 |
|