]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Enhance fuzzcheck so that the --sqlid and --dbid options can specify a
authordrh <>
Mon, 3 Feb 2025 18:36:05 +0000 (18:36 +0000)
committerdrh <>
Mon, 3 Feb 2025 18:36:05 +0000 (18:36 +0000)
range of tests to be run.

FossilOrigin-Name: cdd0af6f86e49ade1339ad5a3cc444400a9722a9efdf84a30b3ff9428b7ac36d

manifest
manifest.uuid
test/fuzzcheck.c

index 6bc22b6c72644463c999a46f5457014cab8edf88..747c094a70e648f01244fa9ccfb3898f552d09e3 100644 (file)
--- 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\sspecify\sa\nrange\sof\stests\sto\sbe\srun.
+D 2025-02-03T18:36:05.574
 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 5445da3b9b509759dc91c7a3c8d660f4056e25ae85274d6fe40c372263ad0bd7
 F test/fuzzdata1.db 3e86d9cf5aea68ddb8e27c02d7dfdaa226347426c7eb814918e4d95475bf8517
 F test/fuzzdata2.db 128b3feeb78918d075c9b14b48610145a0dd4c8d6f1ca7c2870c7e425f5bf31f
 F test/fuzzdata3.db c6586d3e3cef0fbc18108f9bb649aa77bfc38aba
@@ -2209,9 +2209,8 @@ 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
+R bf3f5a9cd383f24f2f19fa2e86a993c0
 U drh
-Z ecbc0f1712cef7fa05faf26775dcb9fc
+Z ca078f36d189947e36e0ecf82c334d57
 # Remove this line to create a well-formed Fossil manifest.
index 2be95918658261c7b36e5fc8c791779932d6f2c1..7e3b1689f6d022228a444a33be4c036d4d2704d0 100644 (file)
@@ -1 +1 @@
-e33f2fedda17b4f3678fc23c438093c256b0c125da5f1ac42ecaf3d604d54b6a
+cdd0af6f86e49ade1339ad5a3cc444400a9722a9efdf84a30b3ff9428b7ac36d
index 390d804df12be49a15020e76d77231978c6b536b..e6b9ed3bb715fe46baf142cf5f2c0ecf41363282 100644 (file)
@@ -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);
   }
@@ -1883,8 +1885,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 +1946,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 +2057,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 +2317,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 +2337,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 +2360,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));