mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
Working when run against sqlite.fossil.
FossilOrigin-Name: b0bd9dd6255be161ea289ba6caa3fbd568128f62
This commit is contained in:
@ -342,7 +342,7 @@ static void scrubBackupOverflow(ScrubState *p, int pgno, u32 nByte){
|
|||||||
if( aBuf==0 ) return;
|
if( aBuf==0 ) return;
|
||||||
while( nByte>0 && pgno!=0 ){
|
while( nByte>0 && pgno!=0 ){
|
||||||
a = scrubBackupRead(p, pgno, aBuf);
|
a = scrubBackupRead(p, pgno, aBuf);
|
||||||
if( a ) break;
|
if( a==0 ) break;
|
||||||
if( nByte >= (p->szUsable)-4 ){
|
if( nByte >= (p->szUsable)-4 ){
|
||||||
nByte -= (p->szUsable) - 4;
|
nByte -= (p->szUsable) - 4;
|
||||||
}else{
|
}else{
|
||||||
@ -372,6 +372,7 @@ static void scrubBackupBtree(ScrubState *p, int pgno, int iDepth){
|
|||||||
u8 *aTop;
|
u8 *aTop;
|
||||||
u8 *aCell;
|
u8 *aCell;
|
||||||
u32 x, y;
|
u32 x, y;
|
||||||
|
int ln = 0;
|
||||||
|
|
||||||
|
|
||||||
if( p->rcErr ) return;
|
if( p->rcErr ) return;
|
||||||
@ -394,21 +395,21 @@ static void scrubBackupBtree(ScrubState *p, int pgno, int iDepth){
|
|||||||
/* Zero out the gap between the cell index and the start of the
|
/* Zero out the gap between the cell index and the start of the
|
||||||
** cell content area */
|
** cell content area */
|
||||||
x = scrubBackupInt16(&aTop[5]); /* First byte of cell content area */
|
x = scrubBackupInt16(&aTop[5]); /* First byte of cell content area */
|
||||||
if( x>p->szUsable ) goto btree_corrupt;
|
if( x>p->szUsable ){ ln=__LINE__; goto btree_corrupt; }
|
||||||
y = szHdr + nPrefix + nCell*2;
|
y = szHdr + nPrefix + nCell*2;
|
||||||
if( y>x ) goto btree_corrupt;
|
if( y>x ){ ln=__LINE__; goto btree_corrupt; }
|
||||||
if( y<x ) memset(a+y, 0, x-y); /* Zero the gap */
|
if( y<x ) memset(a+y, 0, x-y); /* Zero the gap */
|
||||||
|
|
||||||
/* Zero out all the free blocks */
|
/* Zero out all the free blocks */
|
||||||
pc = scrubBackupInt16(&aTop[1]);
|
pc = scrubBackupInt16(&aTop[1]);
|
||||||
if( pc<x+4 ) goto btree_corrupt;
|
if( pc>0 && pc<x ){ ln=__LINE__; goto btree_corrupt; }
|
||||||
while( pc ){
|
while( pc ){
|
||||||
if( pc>(p->szUsable)-4 ) goto btree_corrupt;
|
if( pc>(p->szUsable)-4 ){ ln=__LINE__; goto btree_corrupt; }
|
||||||
n = scrubBackupInt16(&a[pc+2]);
|
n = scrubBackupInt16(&a[pc+2]);
|
||||||
if( pc+n>(p->szUsable) ) goto btree_corrupt;
|
if( pc+n>(p->szUsable) ){ ln=__LINE__; goto btree_corrupt; }
|
||||||
if( n>4 ) memset(&a[pc+4], 0, n-4);
|
if( n>4 ) memset(&a[pc+4], 0, n-4);
|
||||||
x = scrubBackupInt16(&a[pc]);
|
x = scrubBackupInt16(&a[pc]);
|
||||||
if( x<pc+4 && x>0 ) goto btree_corrupt;
|
if( x<pc+4 && x>0 ){ ln=__LINE__; goto btree_corrupt; }
|
||||||
pc = x;
|
pc = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -419,18 +420,18 @@ static void scrubBackupBtree(ScrubState *p, int pgno, int iDepth){
|
|||||||
for(i=0; i<nCell; i++){
|
for(i=0; i<nCell; i++){
|
||||||
u32 X, M, K, nLocal;
|
u32 X, M, K, nLocal;
|
||||||
sqlite3_int64 P;
|
sqlite3_int64 P;
|
||||||
pc = scrubBackupInt16(&aCell[i]);
|
pc = scrubBackupInt16(&aCell[i*2]);
|
||||||
if( pc <= szHdr ) goto btree_corrupt;
|
if( pc <= szHdr ){ ln=__LINE__; goto btree_corrupt; }
|
||||||
if( pc > p->szUsable-3 ) goto btree_corrupt;
|
if( pc > p->szUsable-3 ){ ln=__LINE__; goto btree_corrupt; }
|
||||||
if( aTop[0]==0x05 || aTop[0]==0x02 ){
|
if( aTop[0]==0x05 || aTop[0]==0x02 ){
|
||||||
if( pc+4 > p->szUsable ) goto btree_corrupt;
|
if( pc+4 > p->szUsable ){ ln=__LINE__; goto btree_corrupt; }
|
||||||
iChild = scrubBackupInt32(&a[pc]);
|
iChild = scrubBackupInt32(&a[pc]);
|
||||||
pc += 4;
|
pc += 4;
|
||||||
scrubBackupBtree(p, iChild, iDepth+1);
|
scrubBackupBtree(p, iChild, iDepth+1);
|
||||||
if( aTop[0]==0x05 ) continue;
|
if( aTop[0]==0x05 ) continue;
|
||||||
}
|
}
|
||||||
pc += scrubBackupVarint(&a[pc], &P);
|
pc += scrubBackupVarint(&a[pc], &P);
|
||||||
if( pc >= p->szUsable ) goto btree_corrupt;
|
if( pc >= p->szUsable ){ ln=__LINE__; goto btree_corrupt; }
|
||||||
if( aTop[0]==0x0d ){
|
if( aTop[0]==0x0d ){
|
||||||
X = p->szUsable - 35;
|
X = p->szUsable - 35;
|
||||||
}else{
|
}else{
|
||||||
@ -444,10 +445,10 @@ static void scrubBackupBtree(ScrubState *p, int pgno, int iDepth){
|
|||||||
K = M + ((P-M)%(p->szUsable-4));
|
K = M + ((P-M)%(p->szUsable-4));
|
||||||
if( aTop[0]==0x0d ){
|
if( aTop[0]==0x0d ){
|
||||||
pc += scrubBackupVarintSize(&a[pc]);
|
pc += scrubBackupVarintSize(&a[pc]);
|
||||||
if( pc > (p->szUsable-4) ) goto btree_corrupt;
|
if( pc > (p->szUsable-4) ){ ln=__LINE__; goto btree_corrupt; }
|
||||||
}
|
}
|
||||||
nLocal = K<=X ? K : M;
|
nLocal = K<=X ? K : M;
|
||||||
if( pc+nLocal > p->szUsable-4 ) goto btree_corrupt;
|
if( pc+nLocal > p->szUsable-4 ){ ln=__LINE__; goto btree_corrupt; }
|
||||||
iChild = scrubBackupInt32(&a[pc+nLocal]);
|
iChild = scrubBackupInt32(&a[pc+nLocal]);
|
||||||
scrubBackupOverflow(p, iChild, P-nLocal);
|
scrubBackupOverflow(p, iChild, P-nLocal);
|
||||||
}
|
}
|
||||||
@ -463,7 +464,8 @@ static void scrubBackupBtree(ScrubState *p, int pgno, int iDepth){
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
btree_corrupt:
|
btree_corrupt:
|
||||||
scrubBackupErr(p, "corruption on page %d of source database", pgno);
|
scrubBackupErr(p, "corruption on page %d of source database (errid=%d)",
|
||||||
|
pgno, ln);
|
||||||
if( pgno>1 ) sqlite3_free(a);
|
if( pgno>1 ) sqlite3_free(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -524,7 +526,7 @@ int sqlite3_scrub_backup(
|
|||||||
/* Copy all of the btrees */
|
/* Copy all of the btrees */
|
||||||
scrubBackupBtree(&s, 1, 0);
|
scrubBackupBtree(&s, 1, 0);
|
||||||
pStmt = scrubBackupPrepare(&s, s.dbSrc,
|
pStmt = scrubBackupPrepare(&s, s.dbSrc,
|
||||||
"SELECT rootpage FROM sqlite_master WHERE rootpage IS NOT NULL");
|
"SELECT rootpage FROM sqlite_master WHERE coalesce(rootpage,0)>0");
|
||||||
if( pStmt==0 ) goto scrub_abort;
|
if( pStmt==0 ) goto scrub_abort;
|
||||||
while( sqlite3_step(pStmt)==SQLITE_ROW ){
|
while( sqlite3_step(pStmt)==SQLITE_ROW ){
|
||||||
i = (u32)sqlite3_column_int(pStmt, 0);
|
i = (u32)sqlite3_column_int(pStmt, 0);
|
||||||
|
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
|||||||
C Finished\simplementation\scompiles,\sbut\suntested.
|
C Working\swhen\srun\sagainst\ssqlite.fossil.
|
||||||
D 2016-05-05T23:09:57.111
|
D 2016-05-05T23:39:30.803
|
||||||
F Makefile.in f59e0763ff448719fc1bd25513882b0567286317
|
F Makefile.in f59e0763ff448719fc1bd25513882b0567286317
|
||||||
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
||||||
F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7
|
F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7
|
||||||
@ -215,7 +215,7 @@ F ext/misc/nextchar.c 35c8b8baacb96d92abbb34a83a997b797075b342
|
|||||||
F ext/misc/percentile.c bcbee3c061b884eccb80e21651daaae8e1e43c63
|
F ext/misc/percentile.c bcbee3c061b884eccb80e21651daaae8e1e43c63
|
||||||
F ext/misc/regexp.c a68d25c659bd2d893cd1215667bbf75ecb9dc7d4
|
F ext/misc/regexp.c a68d25c659bd2d893cd1215667bbf75ecb9dc7d4
|
||||||
F ext/misc/rot13.c 1ac6f95f99b575907b9b09c81a349114cf9be45a
|
F ext/misc/rot13.c 1ac6f95f99b575907b9b09c81a349114cf9be45a
|
||||||
F ext/misc/scrub.c 831d12a1ba776815eb946ee5a267997842384074
|
F ext/misc/scrub.c 548a116cb0b4d8705eac392ab13d28fe2aebefe6
|
||||||
F ext/misc/series.c e11e534ada797d5b816d7e7a93c022306563ca35
|
F ext/misc/series.c e11e534ada797d5b816d7e7a93c022306563ca35
|
||||||
F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52
|
F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52
|
||||||
F ext/misc/spellfix.c bf1b922c2750698e9a3d4c50cce6974adb7e93be
|
F ext/misc/spellfix.c bf1b922c2750698e9a3d4c50cce6974adb7e93be
|
||||||
@ -1488,7 +1488,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
|||||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||||
P bdf2ec77d1542d4e9b68218f558710a3efc15823
|
P aeb88bdf6fe9e5839b1503ab5740b27bc09d4842
|
||||||
R 3a64deda8cf94b6b4577af97769133ef
|
R 6bcd08fd9f0774891e37784b87170024
|
||||||
U drh
|
U drh
|
||||||
Z 668555cf9e940e9598a6c547736364c9
|
Z cbd8d4738f2e299be1c42951defbac8d
|
||||||
|
@ -1 +1 @@
|
|||||||
aeb88bdf6fe9e5839b1503ab5740b27bc09d4842
|
b0bd9dd6255be161ea289ba6caa3fbd568128f62
|
Reference in New Issue
Block a user