if( aBuf==0 ) return;
while( nByte>0 && pgno!=0 ){
a = scrubBackupRead(p, pgno, aBuf);
- if( a ) break;
+ if( a==0 ) break;
if( nByte >= (p->szUsable)-4 ){
nByte -= (p->szUsable) - 4;
}else{
u8 *aTop;
u8 *aCell;
u32 x, y;
+ int ln = 0;
if( p->rcErr ) return;
/* Zero out the gap between the cell index and the start of the
** 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;
- 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 */
/* Zero out all the free blocks */
pc = scrubBackupInt16(&aTop[1]);
- if( pc<x+4 ) goto btree_corrupt;
+ if( pc>0 && pc<x ){ ln=__LINE__; goto btree_corrupt; }
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]);
- 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);
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;
}
for(i=0; i<nCell; i++){
u32 X, M, K, nLocal;
sqlite3_int64 P;
- pc = scrubBackupInt16(&aCell[i]);
- if( pc <= szHdr ) goto btree_corrupt;
- if( pc > p->szUsable-3 ) goto btree_corrupt;
+ pc = scrubBackupInt16(&aCell[i*2]);
+ if( pc <= szHdr ){ ln=__LINE__; goto btree_corrupt; }
+ if( pc > p->szUsable-3 ){ ln=__LINE__; goto btree_corrupt; }
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]);
pc += 4;
scrubBackupBtree(p, iChild, iDepth+1);
if( aTop[0]==0x05 ) continue;
}
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 ){
X = p->szUsable - 35;
}else{
K = M + ((P-M)%(p->szUsable-4));
if( aTop[0]==0x0d ){
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;
- 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]);
scrubBackupOverflow(p, iChild, P-nLocal);
}
return;
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);
}
/* Copy all of the btrees */
scrubBackupBtree(&s, 1, 0);
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;
while( sqlite3_step(pStmt)==SQLITE_ROW ){
i = (u32)sqlite3_column_int(pStmt, 0);
-C Finished\simplementation\scompiles,\sbut\suntested.
-D 2016-05-05T23:09:57.111
+C Working\swhen\srun\sagainst\ssqlite.fossil.
+D 2016-05-05T23:39:30.803
F Makefile.in f59e0763ff448719fc1bd25513882b0567286317
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7
F ext/misc/percentile.c bcbee3c061b884eccb80e21651daaae8e1e43c63
F ext/misc/regexp.c a68d25c659bd2d893cd1215667bbf75ecb9dc7d4
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/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52
F ext/misc/spellfix.c bf1b922c2750698e9a3d4c50cce6974adb7e93be
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P bdf2ec77d1542d4e9b68218f558710a3efc15823
-R 3a64deda8cf94b6b4577af97769133ef
+P aeb88bdf6fe9e5839b1503ab5740b27bc09d4842
+R 6bcd08fd9f0774891e37784b87170024
U drh
-Z 668555cf9e940e9598a6c547736364c9
+Z cbd8d4738f2e299be1c42951defbac8d