1
0
mirror of https://github.com/sqlite/sqlite.git synced 2026-10-23 21:49:02 +03:00

In the sqlite3_rsync utility program, fix three defects identified

by Anthropic.

FossilOrigin-Name: b6ab126399a5df66f0f9f4acea470afe8b8b42a28cc679f42e36bd77c1ac3d77
This commit is contained in:
drh
2026-07-09 17:13:12 +00:00
parent 4825267c06
commit ace7cf321b
3 changed files with 20 additions and 14 deletions

View File

@@ -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:33:08.092
C In\sthe\ssqlite3_rsync\sutility\sprogram,\sfix\sthree\sdefects\sidentified\nby\sAnthropic.
D 2026-07-09T17:13:12.109
F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
@@ -2185,7 +2185,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
@@ -2204,9 +2204,9 @@ F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee
F tool/warnings.sh a554d13f6e5cf3760f041b87939e3d616ec6961859c3245e8ef701d1eafc2ca2
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
F tool/winmain.c 00c8fb88e365c9017db14c73d3c78af62194d9644feaf60e220ab0f411f3604c
P 9aac477d65a948b3f32922899b7efbdba72faa48ac9a53cb356feafecffa9c8d
Q +1ce57ba94b63796d5c9b913e3973751ee4f146bdc452ce8b408d2c0cff7f598d
R 8d07959828a80269d6038a088db6a870
P 74a4c3b666c9a8a23f22f4c5a7e039f08adac2bde45fec0349983c262631a19e
Q +805f3acd2b0e81c8274680cbc4cdd6b7b9246df8075ed9caba9e2780729a2740
R 0244776918a0d4af8a73954fa095e781
U drh
Z e871ef9bff928626b2ab9eb635702df4
Z 5e33cb8245275f9ea5eeef3361a261c4
# Remove this line to create a well-formed Fossil manifest.

View File

@@ -1 +1 @@
74a4c3b666c9a8a23f22f4c5a7e039f08adac2bde45fec0349983c262631a19e
b6ab126399a5df66f0f9f4acea470afe8b8b42a28cc679f42e36bd77c1ac3d77

View 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);
}