]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
In the sqlite3_rsync utility program, fix three defects identified by
authordrh <>
Thu, 9 Jul 2026 16:34:26 +0000 (16:34 +0000)
committerdrh <>
Thu, 9 Jul 2026 16:34:26 +0000 (16:34 +0000)
[bugs:/info/e2dfadf51209f12b|Bug e2dfadf51209f12b].

FossilOrigin-Name: 805f3acd2b0e81c8274680cbc4cdd6b7b9246df8075ed9caba9e2780729a2740

manifest
manifest.uuid
tool/sqlite3_rsync.c

index 7cab178edcdfc1842cb9a3711af9de5d2fbd214e..3435f31a134b48bf5822e5ff299ac9a165ba8b9a 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\san\sincorrect\sfree()\scall\sin\sthe\sCLI\son\sWindows\swhen\susing\sthe\s-A\ncommand-line\soption.
-D 2026-07-08T20:30:22.822
+C In\sthe\ssqlite3_rsync\sutility\sprogram,\sfix\sthree\sdefects\sidentified\sby\n[bugs:/info/e2dfadf51209f12b|Bug\se2dfadf51209f12b].
+D 2026-07-09T16:34:26.844
 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
@@ -2195,7 +2195,7 @@ F tool/spellsift.tcl 52b4b04dc4333c7ab024f09d9d66ed6b6f7c6eb00b38497a09f338fa55d
 F tool/split-sqlite3c.tcl 4969fd642dad0ea483e4e104163021d92baf98f6a8eac981fe48525f9b873430
 F tool/sqldiff.c e581749af18f02a72cd18f56b465df1bef630544aebdf13993e2be55e4158f94
 F tool/sqlite3_analyzer.c.in 14f02cb5ec3c264cd6107d1f1dad77092b1cf440fc196c30b69ae87b56a1a43b
-F tool/sqlite3_rsync.c d9ce999e5b3aa9f36de44b321755622e52258774889bd804ba56f00eca01af50
+F tool/sqlite3_rsync.c 4c92b6d720b9447b5112ccfab5d2c350e026add7b25465f657f9338bcc2f4e42
 F tool/sqltclsh.c.in c103c6fc7d42bce611f9d4596774d60b7ef3d0b291a1f58c9e6184e458b89296
 F tool/sqltclsh.tcl 862f4cf1418df5e1315b5db3b5ebe88969e2a784525af5fbf9596592f14ed848
 F tool/src-verify.c 6c655d9a8d6b30f3648fc78a79bf3838ed68f8543869d380c43ea9f17b3b8501
@@ -2214,8 +2214,8 @@ F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee
 F tool/warnings.sh a554d13f6e5cf3760f041b87939e3d616ec6961859c3245e8ef701d1eafc2ca2
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
 F tool/winmain.c 00c8fb88e365c9017db14c73d3c78af62194d9644feaf60e220ab0f411f3604c
-P 4b0882cdb5b7947b23023c13e33f532ca44c0645f6a142a3c7bdb143142d9078
-R 0bc11de58955184ca587db86d1aa7d6a
+P 1ce57ba94b63796d5c9b913e3973751ee4f146bdc452ce8b408d2c0cff7f598d
+R 56866d483b0ee0d1f429199514cac299
 U drh
-Z 15160dbce8a9c98179c72005df7b14ae
+Z 8080e1abb61cdac3fcd460835fd18131
 # Remove this line to create a well-formed Fossil manifest.
index ec5509f931ac1a99acd5c7b8ff9a33f62b6bc377..db7aeb38b623bac3542f54e239789aa4de893525 100644 (file)
@@ -1 +1 @@
-1ce57ba94b63796d5c9b913e3973751ee4f146bdc452ce8b408d2c0cff7f598d
+805f3acd2b0e81c8274680cbc4cdd6b7b9246df8075ed9caba9e2780729a2740
index 2d92ec431338887162dc69279a71e630b86f78b6..3a2e4c3476b2865b07ceb65698386e06282158f9 100644 (file)
@@ -1021,11 +1021,11 @@ void writeByte(SQLiteRsync *p, int c){
   p->nOut++;
 }
 
-/* Read a power of two encoded as a single byte.
+/* Read a power of two page size encoded as a single byte.
 */
 int readPow2(SQLiteRsync *p){
   int x = readByte(p);
-  if( x<0 || x>=32 ){
+  if( x<0 || x>16 ){
     logError(p, "read invalid page size %d\n", x);
     return 0;
   }
@@ -1309,6 +1309,10 @@ static int runSqlReturnText(
 */
 static void closeDb(SQLiteRsync *p){
   if( p->db ){
+    sqlite3_stmt *pStmt;
+    while( (pStmt = sqlite3_next_stmt(p->db, 0))!=0 ){
+      sqlite3_finalize(pStmt);
+    }
     sqlite3_close(p->db);
     p->db = 0;
   }
@@ -1752,7 +1756,6 @@ static void subdivideHashRange(
 static void replicaSide(SQLiteRsync *p){
   int c;
   sqlite3_stmt *pIns = 0;
-  unsigned int szOPage = 0;
   char eJMode = 0;               /* Journal mode prior to sync */
   char buf[65536];
 
@@ -1778,10 +1781,12 @@ static void replicaSide(SQLiteRsync *p){
       case ORIGIN_BEGIN: {
         unsigned int nOPage = 0;
         unsigned int nRPage = 0, szRPage = 0;
+        unsigned int szOPage = 0;
         int rc = 0;
         u8 iProtocol;
 
         closeDb(p);
+        pIns = 0;
         iProtocol = readByte(p);
         szOPage = readPow2(p);
         readUint32(p, &nOPage);
@@ -1811,6 +1816,7 @@ static void replicaSide(SQLiteRsync *p){
           reportError(p, "cannot open in-memory database: %s",
                       sqlite3_errmsg(p->db));
           closeDb(p);
+          pIns = 0;
           break;
         }
         sqlite3_db_config(p->db, SQLITE_DBCONFIG_WRITABLE_SCHEMA, 1, 0);
@@ -1827,6 +1833,7 @@ static void replicaSide(SQLiteRsync *p){
         }
         if( p->nErr ){
           closeDb(p);
+          pIns = 0;
           break;
         }
         runSql(p,
@@ -1935,7 +1942,7 @@ static void replicaSide(SQLiteRsync *p){
           );
           if( pIns==0 ) break;
         }
-        readBytes(p, szOPage, buf);
+        readBytes(p, p->szPage, buf);
         if( p->nErr ) break;
         if( pgno==1 &&  eJMode==2 && buf[18]==1 ){
           /* Do not switch the replica out of WAL mode if it started in 
@@ -1944,7 +1951,7 @@ static void replicaSide(SQLiteRsync *p){
         }
         p->nPageSent++;
         sqlite3_bind_int64(pIns, 1, pgno);
-        sqlite3_bind_blob(pIns, 2, buf, szOPage, SQLITE_STATIC);
+        sqlite3_bind_blob(pIns, 2, buf, p->szPage, SQLITE_STATIC);
         rc = sqlite3_step(pIns);
         if( rc!=SQLITE_DONE ){
           reportError(p, "SQL statement [%s] failed (pgno=%u): %s",
@@ -1961,7 +1968,6 @@ static void replicaSide(SQLiteRsync *p){
     }
   }
 
-  if( pIns ) sqlite3_finalize(pIns);
   closeDb(p);
 }