Update the fuzzcheck test module so that it avoids inserting text values

that contain embedded NULs in the XSQL table.  Fix some legacy entries in
the test/fuzzdata8.db that had embedded NULs.  Add in new dbsqlfuzz cases
that have accumulated over on the dbsqlfuzz project for a while.

FossilOrigin-Name: 47d4240c4a837e829f593bb2aad7563010838f55345e7a0d8e2ea79462aeeb3c
This commit is contained in:
drh 2020-02-25 20:05:58 +00:00
parent f575c1cf06
commit a8781d9d93
4 changed files with 64 additions and 14 deletions

View File

@ -1,5 +1,5 @@
C If\sSTAT4\sdetermines\sthat\sa\sWHERE\sclause\sterm\sthat\sis\snot\sused\sby\san\sindex\nhas\svery\shigh\sprobability\sof\sbeing\strue,\sthen\sdo\snot\suse\sthat\sterm\sto\sreduce\nthe\sestimated\soutput\srow\scount.
D 2020-02-24T17:05:09.915
C Update\sthe\sfuzzcheck\stest\smodule\sso\sthat\sit\savoids\sinserting\stext\svalues\nthat\scontain\sembedded\sNULs\sin\sthe\sXSQL\stable.\s\sFix\ssome\slegacy\sentries\sin\nthe\stest/fuzzdata8.db\sthat\shad\sembedded\sNULs.\s\sAdd\sin\snew\sdbsqlfuzz\scases\nthat\shave\saccumulated\sover\son\sthe\sdbsqlfuzz\sproject\sfor\sa\swhile.
D 2020-02-25T20:05:58.963
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -1015,7 +1015,7 @@ F test/fuzz3.test 9c813e6613b837cb7a277b0383cd66bfa07042b4cf0317157c35852f30043c
F test/fuzz4.test c229bcdb45518a89e1d208a21343e061503460ac69fae1539320a89f572eb634
F test/fuzz_common.tcl b7197de6ed1ee8250a4f82d67876f4561b42ee8cbbfc6160dcb66331bad3f830
F test/fuzz_malloc.test f348276e732e814802e39f042b1f6da6362a610af73a528d8f76898fde6b22f2
F test/fuzzcheck.c a9746aa49843827f960bc875cc70e04b0cfcd3e10e6676e3abc402ad190e165f
F test/fuzzcheck.c f5ed4e174953a4f33cd90891349b9c3e96439a2bfccbd016a3ef4ae97e9aa5d9
F test/fuzzdata1.db d36e88741b4f23bcbaaf55b006290669d03c6c891cf13c7b3a53bc1b097b693f
F test/fuzzdata2.db 128b3feeb78918d075c9b14b48610145a0dd4c8d6f1ca7c2870c7e425f5bf31f
F test/fuzzdata3.db c6586d3e3cef0fbc18108f9bb649aa77bfc38aba
@ -1023,7 +1023,7 @@ F test/fuzzdata4.db b502c7d5498261715812dd8b3c2005bad08b3a26e6489414bd13926cd3e4
F test/fuzzdata5.db e35f64af17ec48926481cfaf3b3855e436bd40d1cfe2d59a9474cb4b748a52a5
F test/fuzzdata6.db 92a80e4afc172c24f662a10a612d188fb272de4a9bd19e017927c95f737de6d7
F test/fuzzdata7.db 0166b56fd7a6b9636a1d60ef0a060f86ddaecf99400a666bb6e5bbd7199ad1f2
F test/fuzzdata8.db 8bd41f8e1b9c61af011bf5cf16a85fb7f718fdd3348e476b78ba36adab872653
F test/fuzzdata8.db 00cd360c354083d69572e82e1da9f582a2ed60760baf9c04558ebadd885d390b
F test/fuzzer1.test 3d4c4b7e547aba5e5511a2991e3e3d07166cfbb8
F test/fuzzer2.test a85ef814ce071293bce1ad8dffa217cbbaad4c14
F test/fuzzerfault.test 8792cd77fd5bce765b05d0c8e01b9edcf8af8536
@ -1859,8 +1859,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P c431b3fd8fd0f6a6974bba3e9366b0430ec003d570e7ce70ceefbcff5fe4b6fa 4558163b6a525990f0f1b6629dbb76daf49bcaf1ddbaf0c50fe05ce9ee480ff8
R 2f59a601b560c09f0f628a3935395fd4
T +closed 4558163b6a525990f0f1b6629dbb76daf49bcaf1ddbaf0c50fe05ce9ee480ff8
P 40739c793b0e98a3bae296d3a1f74944edcdd4cc33c26b417fde4eaf6f14d062
R 02479c6654f151ff7effcb61dc46ff16
U drh
Z 88585aca481f88c3f165f1a6e9b07ffb
Z 417d1fe691d03d97f7ec8cbb9d1cf8da

View File

@ -1 +1 @@
40739c793b0e98a3bae296d3a1f74944edcdd4cc33c26b417fde4eaf6f14d062
47d4240c4a837e829f593bb2aad7563010838f55345e7a0d8e2ea79462aeeb3c

View File

@ -11,8 +11,7 @@
*************************************************************************
**
** This is a utility program designed to aid running regressions tests on
** the SQLite library using data from an external fuzzer, such as American
** Fuzzy Lop (AFL) (http://lcamtuf.coredump.cx/afl/).
** the SQLite library using data from external fuzzers.
**
** This program reads content from an SQLite database file with the following
** schema:
@ -63,6 +62,21 @@
** If fuzzcheck does crash, it can be run in the debugger and the content
** of the global variable g.zTextName[] will identify the specific XSQL and
** DB values that were running when the crash occurred.
**
** DBSQLFUZZ:
**
** The dbsqlfuzz fuzzer includes both a database file and SQL to run against
** that database in its input. This utility can now process dbsqlfuzz
** input files. Load such files using the "--load-dbsql FILE ..." command-line
** option.
**
** Dbsqlfuzz inputs are ordinary text. The first part of the file is text
** that describes the content of the database (using a lot of hexadecimal),
** then there is a divider line followed by the SQL to run against the
** database. Because they are ordinary text, dbsqlfuzz inputs are stored
** in the XSQL table, as if they were ordinary SQL inputs. The isDbSql()
** function can look at a text string and determine whether or not it is
** a valid dbsqlfuzz input.
*/
#include <stdio.h>
#include <stdlib.h>
@ -322,6 +336,39 @@ static void readfileFunc(
fclose(in);
}
/*
** Implementation of the "readtextfile(X)" SQL function. The text content
** of the file named X through the end of the file or to the first \000
** character, whichever comes first, is read and returned as TEXT. NULL
** is returned if the file does not exist or is unreadable.
*/
static void readtextfileFunc(
sqlite3_context *context,
int argc,
sqlite3_value **argv
){
const char *zName;
FILE *in;
long nIn;
char *pBuf;
zName = (const char*)sqlite3_value_text(argv[0]);
if( zName==0 ) return;
in = fopen(zName, "rb");
if( in==0 ) return;
fseek(in, 0, SEEK_END);
nIn = ftell(in);
rewind(in);
pBuf = sqlite3_malloc64( nIn+1 );
if( pBuf && 1==fread(pBuf, nIn, 1, in) ){
pBuf[nIn] = 0;
sqlite3_result_text(context, pBuf, -1, sqlite3_free);
}else{
sqlite3_free(pBuf);
}
fclose(in);
}
/*
** Implementation of the "writefile(X,Y)" SQL function. The argument Y
** is written into file X. The number of bytes written is returned. Or
@ -466,7 +513,7 @@ static int lengthLimit = 1000000;
static int depthLimit = 500;
/* Limit on the amount of heap memory that can be used */
static sqlite3_int64 heapLimit = 1000000000;
static sqlite3_int64 heapLimit = 100000000;
/* Maximum byte-code program length in SQLite */
static int vdbeOpLimit = 25000;
@ -1425,7 +1472,8 @@ int main(int argc, char **argv){
vdbeLimitFlag = 1;
}else
if( strcmp(z,"load-sql")==0 ){
zInsSql = "INSERT INTO xsql(sqltext)VALUES(CAST(readfile(?1) AS text))";
zInsSql = "INSERT INTO xsql(sqltext)"
"VALUES(CAST(readtextfile(?1) AS text))";
iFirstInsArg = i+1;
openFlags4Data = SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE;
break;
@ -1437,7 +1485,8 @@ int main(int argc, char **argv){
break;
}else
if( strcmp(z,"load-dbsql")==0 ){
zInsSql = "INSERT INTO xsql(sqltext)VALUES(CAST(readfile(?1) AS text))";
zInsSql = "INSERT INTO xsql(sqltext)"
"VALUES(CAST(readtextfile(?1) AS text))";
iFirstInsArg = i+1;
openFlags4Data = SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE;
dbSqlOnly = 1;
@ -1623,6 +1672,8 @@ int main(int argc, char **argv){
if( zInsSql ){
sqlite3_create_function(db, "readfile", 1, SQLITE_UTF8, 0,
readfileFunc, 0, 0);
sqlite3_create_function(db, "readtextfile", 1, SQLITE_UTF8, 0,
readtextfileFunc, 0, 0);
sqlite3_create_function(db, "isdbsql", 1, SQLITE_UTF8, 0,
isDbSqlFunc, 0, 0);
rc = sqlite3_prepare_v2(db, zInsSql, -1, &pStmt, 0);

Binary file not shown.