aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrh <>2025-02-03 18:53:02 +0000
committerdrh <>2025-02-03 18:53:02 +0000
commit1c68deead787c4e8aefabd72c684ddf0f620a14c (patch)
treed3a8d5ce1b8ec94f3afaf5bb00a0296f50a2f83a
parentc2b446f16a0902a015a046489db6d14ceb8b1bd6 (diff)
parent589796cd890c8be02a92dcbb3e2a0bcb248b6a75 (diff)
downloadsqlite-1c68deead787c4e8aefabd72c684ddf0f620a14c.tar.gz
sqlite-1c68deead787c4e8aefabd72c684ddf0f620a14c.zip
Enhance fuzzcheck so that the --sqlid and --dbid options can take a range
of IDs to run. FossilOrigin-Name: 408fa57f048e05a261fb62b45ae44b8a97c97fc01e3776124cbef6595df579d4
-rw-r--r--manifest14
-rw-r--r--manifest.uuid2
-rw-r--r--test/fuzzcheck.c63
3 files changed, 54 insertions, 25 deletions
diff --git a/manifest b/manifest
index 6bc22b6c7..6b13e86cc 100644
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sfor\sa\spotential\sUAF\sin\sFTS5.
-D 2025-02-03T18:05:54.347
+C Enhance\sfuzzcheck\sso\sthat\sthe\s--sqlid\sand\s--dbid\soptions\scan\stake\sa\srange\nof\sIDs\sto\srun.
+D 2025-02-03T18:53:02.874
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d
@@ -1277,7 +1277,7 @@ F test/fuzz3.test 70ba57260364b83e964707b9d4b5625284239768ab907dd387c740c0370ce3
F test/fuzz4.test c229bcdb45518a89e1d208a21343e061503460ac69fae1539320a89f572eb634
F test/fuzz_common.tcl b7197de6ed1ee8250a4f82d67876f4561b42ee8cbbfc6160dcb66331bad3f830
F test/fuzz_malloc.test f348276e732e814802e39f042b1f6da6362a610af73a528d8f76898fde6b22f2
-F test/fuzzcheck.c 1671559091b3e134ec807490f624d306b24bd9a8f03b12aa97e292f4b31e5d96
+F test/fuzzcheck.c 6fc952750a69168dd5fea38b9d35cb38475bfda15c8acfd156ac09cd03ddbd3e
F test/fuzzdata1.db 3e86d9cf5aea68ddb8e27c02d7dfdaa226347426c7eb814918e4d95475bf8517
F test/fuzzdata2.db 128b3feeb78918d075c9b14b48610145a0dd4c8d6f1ca7c2870c7e425f5bf31f
F test/fuzzdata3.db c6586d3e3cef0fbc18108f9bb649aa77bfc38aba
@@ -2209,9 +2209,9 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350
F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 9f27379d860518e6e097a2c999da04176812260a61bf11fe495c3efd76971806 a4962df665084e423e020be9a2834b6886a8e3feb461cff5358b61398a2a20d2
-R 0c55f60057cb31a548300850eb056c7d
-T +closed a4962df665084e423e020be9a2834b6886a8e3feb461cff5358b61398a2a20d2
+P e33f2fedda17b4f3678fc23c438093c256b0c125da5f1ac42ecaf3d604d54b6a 59e26632449163a36b803cc7027ed99c1f6b675dda6f0b2b12bbe55884923f08
+R 97da3e589df10edb12f045b63fd334d3
+T +closed 59e26632449163a36b803cc7027ed99c1f6b675dda6f0b2b12bbe55884923f08
U drh
-Z ecbc0f1712cef7fa05faf26775dcb9fc
+Z c70a3622de374067746199fda23d1690
# Remove this line to create a well-formed Fossil manifest.
diff --git a/manifest.uuid b/manifest.uuid
index 2be959186..486d20023 100644
--- a/manifest.uuid
+++ b/manifest.uuid
@@ -1 +1 @@
-e33f2fedda17b4f3678fc23c438093c256b0c125da5f1ac42ecaf3d604d54b6a
+408fa57f048e05a261fb62b45ae44b8a97c97fc01e3776124cbef6595df579d4
diff --git a/test/fuzzcheck.c b/test/fuzzcheck.c
index 390d804df..84e3f3289 100644
--- a/test/fuzzcheck.c
+++ b/test/fuzzcheck.c
@@ -507,7 +507,8 @@ static void writefileFunc(
static void blobListLoadFromDb(
sqlite3 *db, /* Read from this database */
const char *zSql, /* Query used to extract the blobs */
- int onlyId, /* Only load where id is this value */
+ int firstId, /* First sqlid to load */
+ int lastId, /* Last sqlid to load */
int *pN, /* OUT: Write number of blobs loaded here */
Blob **ppList /* OUT: Write the head of the blob list here */
){
@@ -518,8 +519,9 @@ static void blobListLoadFromDb(
int rc;
char *z2;
- if( onlyId>0 ){
- z2 = sqlite3_mprintf("%s WHERE rowid=%d", zSql, onlyId);
+ if( firstId>0 ){
+ z2 = sqlite3_mprintf("%s WHERE rowid BETWEEN %d AND %d", zSql,
+ firstId, lastId);
}else{
z2 = sqlite3_mprintf("%s", zSql);
}
@@ -1836,7 +1838,8 @@ static void showHelp(void){
"each database, checking for crashes and memory leaks.\n"
"Options:\n"
" --cell-size-check Set the PRAGMA cell_size_check=ON\n"
-" --dbid N Use only the database where dbid=N\n"
+" --dbid M..N Use only the databases where dbid between M and N\n"
+" \"M..\" for M and afterwards. Just \"M\" for M only\n"
" --export-db DIR Write databases to files(s) in DIR. Works with --dbid\n"
" --export-sql DIR Write SQL to file(s) in DIR. Also works with --sqlid\n"
" --help Show this help text\n"
@@ -1861,7 +1864,8 @@ static void showHelp(void){
" --script Output CLI script instead of running tests\n"
" --skip N Skip the first N test cases\n"
" --spinner Use a spinner to show progress\n"
-" --sqlid N Use only SQL where sqlid=N\n"
+" --sqlid M..N Use only SQL where sqlid between M..N\n"
+" \"M..\" for M and afterwards. Just \"M\" for M only\n"
" --timeout N Maximum time for any one test in N millseconds\n"
" -v|--verbose Increased output. Repeat for more output.\n"
" --vdbe-debug Activate VDBE debugging.\n"
@@ -1883,8 +1887,10 @@ int main(int argc, char **argv){
Blob *pDb; /* For looping over template databases */
int i; /* Loop index for the argv[] loop */
int dbSqlOnly = 0; /* Only use scripts that are dbsqlfuzz */
- int onlySqlid = -1; /* --sqlid */
- int onlyDbid = -1; /* --dbid */
+ int firstSqlid = -1; /* First --sqlid range */
+ int lastSqlid = 0x7fffffff; /* Last --sqlid range */
+ int firstDbid = -1; /* --dbid */
+ int lastDbid = 0x7fffffff; /* --dbid end */
int nativeFlag = 0; /* --native-vfs */
int rebuildFlag = 0; /* --rebuild */
int vdbeLimitFlag = 0; /* --limit-vdbe */
@@ -1942,8 +1948,18 @@ int main(int argc, char **argv){
cellSzCkFlag = 1;
}else
if( strcmp(z,"dbid")==0 ){
+ const char *zDotDot;
if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]);
- onlyDbid = integerValue(argv[++i]);
+ i++;
+ zDotDot = strstr(argv[i], "..");
+ if( zDotDot ){
+ firstDbid = atoi(argv[i]);
+ if( zDotDot[2] ){
+ lastDbid = atoi(&zDotDot[2]);
+ }
+ }else{
+ lastDbid = firstDbid = integerValue(argv[i]);
+ }
}else
if( strcmp(z,"export-db")==0 ){
if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]);
@@ -2043,8 +2059,19 @@ int main(int argc, char **argv){
bTimer = 1;
}else
if( strcmp(z,"sqlid")==0 ){
+ const char *zDotDot;
if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]);
- onlySqlid = integerValue(argv[++i]);
+ i++;
+ zDotDot = strstr(argv[i], "..");
+ if( zDotDot ){
+ firstSqlid = atoi(argv[i]);
+ if( zDotDot[2] ){
+ lastSqlid = atoi(&zDotDot[2]);
+ }
+ }else{
+ firstSqlid = integerValue(argv[i]);
+ lastSqlid = firstSqlid;
+ }
}else
if( strcmp(z,"timeout")==0 ){
if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]);
@@ -2292,13 +2319,14 @@ int main(int argc, char **argv){
const char *zExDb =
"SELECT writefile(printf('%s/db%06d.db',?1,dbid),dbcontent),"
" dbid, printf('%s/db%06d.db',?1,dbid), length(dbcontent)"
- " FROM db WHERE ?2<0 OR dbid=?2;";
+ " FROM db WHERE dbid BETWEEN ?2 AND ?3;";
rc = sqlite3_prepare_v2(db, zExDb, -1, &pStmt, 0);
if( rc ) fatalError("cannot prepare statement [%s]: %s",
zExDb, sqlite3_errmsg(db));
sqlite3_bind_text64(pStmt, 1, zExpDb, strlen(zExpDb),
SQLITE_STATIC, SQLITE_UTF8);
- sqlite3_bind_int(pStmt, 2, onlyDbid);
+ sqlite3_bind_int(pStmt, 2, firstDbid);
+ sqlite3_bind_int(pStmt, 3, lastDbid);
while( sqlite3_step(pStmt)==SQLITE_ROW ){
printf("write db-%d (%d bytes) into %s\n",
sqlite3_column_int(pStmt,1),
@@ -2311,13 +2339,14 @@ int main(int argc, char **argv){
const char *zExSql =
"SELECT writefile(printf('%s/sql%06d.txt',?1,sqlid),sqltext),"
" sqlid, printf('%s/sql%06d.txt',?1,sqlid), length(sqltext)"
- " FROM xsql WHERE ?2<0 OR sqlid=?2;";
+ " FROM xsql WHERE sqlid BETWEEN ?2 AND ?3;";
rc = sqlite3_prepare_v2(db, zExSql, -1, &pStmt, 0);
if( rc ) fatalError("cannot prepare statement [%s]: %s",
zExSql, sqlite3_errmsg(db));
sqlite3_bind_text64(pStmt, 1, zExpSql, strlen(zExpSql),
SQLITE_STATIC, SQLITE_UTF8);
- sqlite3_bind_int(pStmt, 2, onlySqlid);
+ sqlite3_bind_int(pStmt, 2, firstSqlid);
+ sqlite3_bind_int(pStmt, 3, lastSqlid);
while( sqlite3_step(pStmt)==SQLITE_ROW ){
printf("write sql-%d (%d bytes) into %s\n",
sqlite3_column_int(pStmt,1),
@@ -2333,11 +2362,11 @@ int main(int argc, char **argv){
/* Load all SQL script content and all initial database images from the
** source db
*/
- blobListLoadFromDb(db, "SELECT sqlid, sqltext FROM xsql", onlySqlid,
- &g.nSql, &g.pFirstSql);
+ blobListLoadFromDb(db, "SELECT sqlid, sqltext FROM xsql", firstSqlid,
+ lastSqlid, &g.nSql, &g.pFirstSql);
if( g.nSql==0 ) fatalError("need at least one SQL script");
- blobListLoadFromDb(db, "SELECT dbid, dbcontent FROM db", onlyDbid,
- &g.nDb, &g.pFirstDb);
+ blobListLoadFromDb(db, "SELECT dbid, dbcontent FROM db", firstDbid,
+ lastDbid, &g.nDb, &g.pFirstDb);
if( g.nDb==0 ){
g.pFirstDb = safe_realloc(0, sizeof(Blob));
memset(g.pFirstDb, 0, sizeof(Blob));